1 /********************************************************************
4 Description: Driver for the VIA VT8231/VT8233 IrDA chipsets
5 Author: VIA Technologies,inc
8 Copyright (c) 1998-2003 VIA Technologies, Inc.
10 This program is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free Software
12 Foundation; either version 2, or (at your option) any later version.
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTIES OR REPRESENTATIONS; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 See the GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License along with
20 this program; if not, write to the Free Software Foundation, Inc.,
21 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 F01 Oct/02/02: Modify code for V0.11(move out back to back transfer)
24 F02 Oct/28/02: Add SB device ID for 3147 and 3177.
26 jul/09/2002 : only implement two kind of dongle currently.
27 Oct/02/2002 : work on VT8231 and VT8233 .
28 Aug/06/2003 : change driver format to pci driver .
30 2004-02-16: <sda@bdit.de>
31 - Removed unneeded 'legacy' pci stuff.
32 - Make sure SIR mode is set (hw_init()) before calling mode-dependant stuff.
33 - On speed change from core, don't send SIR frame with new speed.
34 Use current speed and change speeds later.
35 - Make module-param dongle_id actually work.
36 - New dongle_id 17 (0x11): TDFS4500. Single-ended SIR only.
37 Tested with home-grown PCB on EPIA boards.
40 ********************************************************************/
41 #include <linux/module.h>
42 #include <linux/kernel.h>
43 #include <linux/types.h>
44 #include <linux/skbuff.h>
45 #include <linux/netdevice.h>
46 #include <linux/ioport.h>
47 #include <linux/delay.h>
48 #include <linux/slab.h>
49 #include <linux/init.h>
50 #include <linux/rtnetlink.h>
51 #include <linux/pci.h>
52 #include <linux/dma-mapping.h>
56 #include <asm/byteorder.h>
60 #include <net/irda/wrapper.h>
61 #include <net/irda/irda.h>
62 #include <net/irda/irda_device.h>
66 #define VIA_MODULE_NAME "via-ircc"
67 #define CHIP_IO_EXTENT 0x40
69 static char *driver_name = VIA_MODULE_NAME;
71 /* Module parameters */
72 static int qos_mtt_bits = 0x07; /* 1 ms or more */
73 static int dongle_id = 0; /* default: probe */
75 /* We can't guess the type of connected dongle, user *must* supply it. */
76 module_param(dongle_id, int, 0);
78 /* FIXME : we should not need this, because instances should be automatically
79 * managed by the PCI layer. Especially that we seem to only be using the
80 * first entry. Jean II */
81 /* Max 4 instances for now */
82 static struct via_ircc_cb *dev_self[] = { NULL, NULL, NULL, NULL };
85 static int via_ircc_open(int i, chipio_t * info, unsigned int id);
86 static int via_ircc_close(struct via_ircc_cb *self);
87 static int via_ircc_dma_receive(struct via_ircc_cb *self);
88 static int via_ircc_dma_receive_complete(struct via_ircc_cb *self,
90 static int via_ircc_hard_xmit_sir(struct sk_buff *skb,
91 struct net_device *dev);
92 static int via_ircc_hard_xmit_fir(struct sk_buff *skb,
93 struct net_device *dev);
94 static void via_hw_init(struct via_ircc_cb *self);
95 static void via_ircc_change_speed(struct via_ircc_cb *self, __u32 baud);
96 static irqreturn_t via_ircc_interrupt(int irq, void *dev_id);
97 static int via_ircc_is_receiving(struct via_ircc_cb *self);
98 static int via_ircc_read_dongle_id(int iobase);
100 static int via_ircc_net_open(struct net_device *dev);
101 static int via_ircc_net_close(struct net_device *dev);
102 static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq,
104 static struct net_device_stats *via_ircc_net_get_stats(struct net_device
106 static void via_ircc_change_dongle_speed(int iobase, int speed,
108 static int RxTimerHandler(struct via_ircc_cb *self, int iobase);
109 static void hwreset(struct via_ircc_cb *self);
110 static int via_ircc_dma_xmit(struct via_ircc_cb *self, u16 iobase);
111 static int upload_rxdata(struct via_ircc_cb *self, int iobase);
112 static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_device_id *id);
113 static void __devexit via_remove_one (struct pci_dev *pdev);
115 /* FIXME : Should use udelay() instead, even if we are x86 only - Jean II */
116 static void iodelay(int udelay)
121 for (i = 0; i < udelay; i++) {
126 static struct pci_device_id via_pci_tbl[] = {
127 { PCI_VENDOR_ID_VIA, 0x8231, PCI_ANY_ID, PCI_ANY_ID,0,0,0 },
128 { PCI_VENDOR_ID_VIA, 0x3109, PCI_ANY_ID, PCI_ANY_ID,0,0,1 },
129 { PCI_VENDOR_ID_VIA, 0x3074, PCI_ANY_ID, PCI_ANY_ID,0,0,2 },
130 { PCI_VENDOR_ID_VIA, 0x3147, PCI_ANY_ID, PCI_ANY_ID,0,0,3 },
131 { PCI_VENDOR_ID_VIA, 0x3177, PCI_ANY_ID, PCI_ANY_ID,0,0,4 },
135 MODULE_DEVICE_TABLE(pci,via_pci_tbl);
138 static struct pci_driver via_driver = {
139 .name = VIA_MODULE_NAME,
140 .id_table = via_pci_tbl,
141 .probe = via_init_one,
142 .remove = __devexit_p(via_remove_one),
147 * Function via_ircc_init ()
149 * Initialize chip. Just find out chip type and resource.
151 static int __init via_ircc_init(void)
155 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
157 rc = pci_register_driver(&via_driver);
159 IRDA_DEBUG(0, "%s(): error rc = %d, returning -ENODEV...\n",
166 static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_device_id *id)
169 u8 temp,oldPCI_40,oldPCI_44,bTmp,bTmp1;
170 u16 Chipset,FirDRQ1,FirDRQ0,FirIRQ,FirIOBase;
173 IRDA_DEBUG(2, "%s(): Device ID=(0X%X)\n", __FUNCTION__, id->device);
175 rc = pci_enable_device (pcidev);
177 IRDA_DEBUG(0, "%s(): error rc = %d\n", __FUNCTION__, rc);
181 // South Bridge exist
182 if ( ReadLPCReg(0x20) != 0x3C )
187 if (Chipset==0x3076) {
188 IRDA_DEBUG(2, "%s(): Chipset = 3076\n", __FUNCTION__);
190 WriteLPCReg(7,0x0c );
191 temp=ReadLPCReg(0x30);//check if BIOS Enable Fir
192 if((temp&0x01)==1) { // BIOS close or no FIR
193 WriteLPCReg(0x1d, 0x82 );
194 WriteLPCReg(0x23,0x18);
195 temp=ReadLPCReg(0xF0);
197 temp=(ReadLPCReg(0x74)&0x03); //DMA
199 temp=(ReadLPCReg(0x74)&0x0C) >> 2;
202 temp=(ReadLPCReg(0x74)&0x0C) >> 2; //DMA
206 FirIRQ=(ReadLPCReg(0x70)&0x0f); //IRQ
207 FirIOBase=ReadLPCReg(0x60 ) << 8; //IO Space :high byte
208 FirIOBase=FirIOBase| ReadLPCReg(0x61) ; //low byte
209 FirIOBase=FirIOBase ;
210 info.fir_base=FirIOBase;
214 pci_read_config_byte(pcidev,0x40,&bTmp);
215 pci_write_config_byte(pcidev,0x40,((bTmp | 0x08) & 0xfe));
216 pci_read_config_byte(pcidev,0x42,&bTmp);
217 pci_write_config_byte(pcidev,0x42,(bTmp | 0xf0));
218 pci_write_config_byte(pcidev,0x5a,0xc0);
219 WriteLPCReg(0x28, 0x70 );
220 if (via_ircc_open(0, &info,0x3076) == 0)
223 rc = -ENODEV; //IR not turn on
224 } else { //Not VT1211
225 IRDA_DEBUG(2, "%s(): Chipset = 3096\n", __FUNCTION__);
227 pci_read_config_byte(pcidev,0x67,&bTmp);//check if BIOS Enable Fir
228 if((bTmp&0x01)==1) { // BIOS enable FIR
229 //Enable Double DMA clock
230 pci_read_config_byte(pcidev,0x42,&oldPCI_40);
231 pci_write_config_byte(pcidev,0x42,oldPCI_40 | 0x80);
232 pci_read_config_byte(pcidev,0x40,&oldPCI_40);
233 pci_write_config_byte(pcidev,0x40,oldPCI_40 & 0xf7);
234 pci_read_config_byte(pcidev,0x44,&oldPCI_44);
235 pci_write_config_byte(pcidev,0x44,0x4e);
236 //---------- read configuration from Function0 of south bridge
238 pci_read_config_byte(pcidev,0x44,&bTmp1); //DMA
239 FirDRQ0 = (bTmp1 & 0x30) >> 4;
240 pci_read_config_byte(pcidev,0x44,&bTmp1);
241 FirDRQ1 = (bTmp1 & 0xc0) >> 6;
243 pci_read_config_byte(pcidev,0x44,&bTmp1); //DMA
244 FirDRQ0 = (bTmp1 & 0x30) >> 4 ;
247 pci_read_config_byte(pcidev,0x47,&bTmp1); //IRQ
248 FirIRQ = bTmp1 & 0x0f;
250 pci_read_config_byte(pcidev,0x69,&bTmp);
251 FirIOBase = bTmp << 8;//hight byte
252 pci_read_config_byte(pcidev,0x68,&bTmp);
253 FirIOBase = (FirIOBase | bTmp ) & 0xfff0;
254 //-------------------------
255 info.fir_base=FirIOBase;
259 if (via_ircc_open(0, &info,0x3096) == 0)
262 rc = -ENODEV; //IR not turn on !!!!!
265 IRDA_DEBUG(2, "%s(): End - rc = %d\n", __FUNCTION__, rc);
270 * Function via_ircc_clean ()
272 * Close all configured chips
275 static void via_ircc_clean(void)
279 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
281 for (i=0; i < ARRAY_SIZE(dev_self); i++) {
283 via_ircc_close(dev_self[i]);
287 static void __devexit via_remove_one (struct pci_dev *pdev)
289 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
291 /* FIXME : This is ugly. We should use pci_get_drvdata(pdev);
292 * to get our driver instance and call directly via_ircc_close().
293 * See vlsi_ir for details...
297 /* FIXME : This should be in via_ircc_close(), because here we may
298 * theoritically disable still configured devices :-( - Jean II */
299 pci_disable_device(pdev);
302 static void __exit via_ircc_cleanup(void)
304 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
306 /* FIXME : This should be redundant, as pci_unregister_driver()
307 * should call via_remove_one() on each device.
311 /* Cleanup all instances of the driver */
312 pci_unregister_driver (&via_driver);
316 * Function via_ircc_open (iobase, irq)
318 * Open driver instance
321 static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
323 struct net_device *dev;
324 struct via_ircc_cb *self;
327 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
329 if (i >= ARRAY_SIZE(dev_self))
332 /* Allocate new instance of the driver */
333 dev = alloc_irdadev(sizeof(struct via_ircc_cb));
339 spin_lock_init(&self->lock);
341 /* FIXME : We should store our driver instance in the PCI layer,
342 * using pci_set_drvdata(), not in this array.
343 * See vlsi_ir for details... - Jean II */
344 /* FIXME : 'i' is always 0 (see via_init_one()) :-( - Jean II */
345 /* Need to store self somewhere */
348 /* Initialize Resource */
349 self->io.cfg_base = info->cfg_base;
350 self->io.fir_base = info->fir_base;
351 self->io.irq = info->irq;
352 self->io.fir_ext = CHIP_IO_EXTENT;
353 self->io.dma = info->dma;
354 self->io.dma2 = info->dma2;
355 self->io.fifo_size = 32;
357 self->st_fifo.len = 0;
358 self->RxDataReady = 0;
360 /* Reserve the ioports that we need */
361 if (!request_region(self->io.fir_base, self->io.fir_ext, driver_name)) {
362 IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n",
363 __FUNCTION__, self->io.fir_base);
368 /* Initialize QoS for this device */
369 irda_init_max_qos_capabilies(&self->qos);
371 /* Check if user has supplied the dongle id or not */
373 dongle_id = via_ircc_read_dongle_id(self->io.fir_base);
374 self->io.dongle_id = dongle_id;
376 /* The only value we must override it the baudrate */
377 /* Maximum speeds and capabilities are dongle-dependant. */
378 switch( self->io.dongle_id ){
380 self->qos.baud_rate.bits =
381 IR_9600 | IR_19200 | IR_38400 | IR_57600 | IR_115200 |
382 IR_576000 | IR_1152000 | (IR_4000000 << 8);
385 self->qos.baud_rate.bits =
386 IR_9600 | IR_19200 | IR_38400 | IR_57600 | IR_115200;
390 /* Following was used for testing:
392 * self->qos.baud_rate.bits = IR_9600;
394 * Is is no good, as it prohibits (error-prone) speed-changes.
397 self->qos.min_turn_time.bits = qos_mtt_bits;
398 irda_qos_bits_to_value(&self->qos);
400 /* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */
401 self->rx_buff.truesize = 14384 + 2048;
402 self->tx_buff.truesize = 14384 + 2048;
404 /* Allocate memory if needed */
406 dma_alloc_coherent(NULL, self->rx_buff.truesize,
407 &self->rx_buff_dma, GFP_KERNEL);
408 if (self->rx_buff.head == NULL) {
412 memset(self->rx_buff.head, 0, self->rx_buff.truesize);
415 dma_alloc_coherent(NULL, self->tx_buff.truesize,
416 &self->tx_buff_dma, GFP_KERNEL);
417 if (self->tx_buff.head == NULL) {
421 memset(self->tx_buff.head, 0, self->tx_buff.truesize);
423 self->rx_buff.in_frame = FALSE;
424 self->rx_buff.state = OUTSIDE_FRAME;
425 self->tx_buff.data = self->tx_buff.head;
426 self->rx_buff.data = self->rx_buff.head;
428 /* Reset Tx queue info */
429 self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
430 self->tx_fifo.tail = self->tx_buff.head;
432 /* Keep track of module usage */
433 SET_MODULE_OWNER(dev);
435 /* Override the network functions we need to use */
436 dev->hard_start_xmit = via_ircc_hard_xmit_sir;
437 dev->open = via_ircc_net_open;
438 dev->stop = via_ircc_net_close;
439 dev->do_ioctl = via_ircc_net_ioctl;
440 dev->get_stats = via_ircc_net_get_stats;
442 err = register_netdev(dev);
446 IRDA_MESSAGE("IrDA: Registered device %s (via-ircc)\n", dev->name);
448 /* Initialise the hardware..
450 self->io.speed = 9600;
454 dma_free_coherent(NULL, self->tx_buff.truesize,
455 self->tx_buff.head, self->tx_buff_dma);
457 dma_free_coherent(NULL, self->rx_buff.truesize,
458 self->rx_buff.head, self->rx_buff_dma);
460 release_region(self->io.fir_base, self->io.fir_ext);
468 * Function via_ircc_close (self)
470 * Close driver instance
473 static int via_ircc_close(struct via_ircc_cb *self)
477 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
479 IRDA_ASSERT(self != NULL, return -1;);
481 iobase = self->io.fir_base;
483 ResetChip(iobase, 5); //hardware reset.
484 /* Remove netdevice */
485 unregister_netdev(self->netdev);
487 /* Release the PORT that this driver is using */
488 IRDA_DEBUG(2, "%s(), Releasing Region %03x\n",
489 __FUNCTION__, self->io.fir_base);
490 release_region(self->io.fir_base, self->io.fir_ext);
491 if (self->tx_buff.head)
492 dma_free_coherent(NULL, self->tx_buff.truesize,
493 self->tx_buff.head, self->tx_buff_dma);
494 if (self->rx_buff.head)
495 dma_free_coherent(NULL, self->rx_buff.truesize,
496 self->rx_buff.head, self->rx_buff_dma);
497 dev_self[self->index] = NULL;
499 free_netdev(self->netdev);
505 * Function via_hw_init(self)
507 * Returns non-negative on success.
509 * Formerly via_ircc_setup
511 static void via_hw_init(struct via_ircc_cb *self)
513 int iobase = self->io.fir_base;
515 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
517 SetMaxRxPacketSize(iobase, 0x0fff); //set to max:4095
519 EnRXFIFOReadyInt(iobase, OFF);
520 EnRXFIFOHalfLevelInt(iobase, OFF);
521 EnTXFIFOHalfLevelInt(iobase, OFF);
522 EnTXFIFOUnderrunEOMInt(iobase, ON);
523 EnTXFIFOReadyInt(iobase, OFF);
524 InvertTX(iobase, OFF);
525 InvertRX(iobase, OFF);
527 if (ReadLPCReg(0x20) == 0x3c)
528 WriteLPCReg(0xF0, 0); // for VT1211
530 EnRXSpecInt(iobase, ON);
532 /* The following is basically hwreset */
533 /* If this is the case, why not just call hwreset() ? Jean II */
534 ResetChip(iobase, 5);
535 EnableDMA(iobase, OFF);
536 EnableTX(iobase, OFF);
537 EnableRX(iobase, OFF);
538 EnRXDMA(iobase, OFF);
539 EnTXDMA(iobase, OFF);
540 RXStart(iobase, OFF);
541 TXStart(iobase, OFF);
544 SIRFilter(iobase, ON);
548 WriteReg(iobase, I_ST_CT_0, 0x00);
549 SetBaudRate(iobase, 9600);
550 SetPulseWidth(iobase, 12);
551 SetSendPreambleCount(iobase, 0);
553 self->io.speed = 9600;
554 self->st_fifo.len = 0;
556 via_ircc_change_dongle_speed(iobase, self->io.speed,
559 WriteReg(iobase, I_ST_CT_0, 0x80);
563 * Function via_ircc_read_dongle_id (void)
566 static int via_ircc_read_dongle_id(int iobase)
568 int dongle_id = 9; /* Default to IBM */
570 IRDA_ERROR("via-ircc: dongle probing not supported, please specify dongle_id module parameter.\n");
575 * Function via_ircc_change_dongle_speed (iobase, speed, dongle_id)
576 * Change speed of the attach dongle
577 * only implement two type of dongle currently.
579 static void via_ircc_change_dongle_speed(int iobase, int speed,
584 /* speed is unused, as we use IsSIROn()/IsMIROn() */
587 IRDA_DEBUG(1, "%s(): change_dongle_speed to %d for 0x%x, %d\n",
588 __FUNCTION__, speed, iobase, dongle_id);
592 /* Note: The dongle_id's listed here are derived from
595 case 0x08: /* HP HSDL-2300, HP HSDL-3600/HSDL-3610 */
596 UseOneRX(iobase, ON); // use one RX pin RX1,RX2
597 InvertTX(iobase, OFF);
598 InvertRX(iobase, OFF);
600 EnRX2(iobase, ON); //sir to rx2
601 EnGPIOtoRX2(iobase, OFF);
603 if (IsSIROn(iobase)) { //sir
605 SlowIRRXLowActive(iobase, ON);
607 SlowIRRXLowActive(iobase, OFF);
609 if (IsMIROn(iobase)) { //mir
611 SlowIRRXLowActive(iobase, OFF);
614 if (IsFIROn(iobase)) { //fir
616 SlowIRRXLowActive(iobase, OFF);
623 case 0x09: /* IBM31T1100 or Temic TFDS6000/TFDS6500 */
624 UseOneRX(iobase, ON); //use ONE RX....RX1
625 InvertTX(iobase, OFF);
626 InvertRX(iobase, OFF); // invert RX pin
629 EnGPIOtoRX2(iobase, OFF);
630 if (IsSIROn(iobase)) { //sir
632 SlowIRRXLowActive(iobase, ON);
635 SlowIRRXLowActive(iobase, OFF);
637 if (IsMIROn(iobase)) { //mir
639 SlowIRRXLowActive(iobase, OFF);
642 SlowIRRXLowActive(iobase, ON);
644 if (IsFIROn(iobase)) { //fir
646 SlowIRRXLowActive(iobase, OFF);
651 SlowIRRXLowActive(iobase, ON);
654 WriteTX(iobase, OFF);
660 UseOneRX(iobase, OFF); // use two RX pin RX1,RX2
661 InvertTX(iobase, OFF);
662 InvertRX(iobase, OFF);
663 SlowIRRXLowActive(iobase, OFF);
664 if (IsSIROn(iobase)) { //sir
665 EnGPIOtoRX2(iobase, OFF);
666 WriteGIO(iobase, OFF);
667 EnRX2(iobase, OFF); //sir to rx2
669 EnGPIOtoRX2(iobase, OFF);
670 WriteGIO(iobase, OFF);
671 EnRX2(iobase, OFF); //fir to rx
675 case 0x11: /* Temic TFDS4500 */
677 IRDA_DEBUG(2, "%s: Temic TFDS4500: One RX pin, TX normal, RX inverted.\n", __FUNCTION__);
679 UseOneRX(iobase, ON); //use ONE RX....RX1
680 InvertTX(iobase, OFF);
681 InvertRX(iobase, ON); // invert RX pin
683 EnRX2(iobase, ON); //sir to rx2
684 EnGPIOtoRX2(iobase, OFF);
686 if( IsSIROn(iobase) ){ //sir
689 SlowIRRXLowActive(iobase, ON);
692 SlowIRRXLowActive(iobase, OFF);
695 IRDA_DEBUG(0, "%s: Warning: TFDS4500 not running in SIR mode !\n", __FUNCTION__);
699 case 0x0ff: /* Vishay */
702 else if (IsMIROn(iobase))
704 else if (IsFIROn(iobase))
706 else if (IsVFIROn(iobase))
708 SI_SetMode(iobase, mode);
712 IRDA_ERROR("%s: Error: dongle_id %d unsupported !\n",
713 __FUNCTION__, dongle_id);
718 * Function via_ircc_change_speed (self, baud)
720 * Change the speed of the device
723 static void via_ircc_change_speed(struct via_ircc_cb *self, __u32 speed)
725 struct net_device *dev = self->netdev;
729 iobase = self->io.fir_base;
730 /* Update accounting for new speed */
731 self->io.speed = speed;
732 IRDA_DEBUG(1, "%s: change_speed to %d bps.\n", __FUNCTION__, speed);
734 WriteReg(iobase, I_ST_CT_0, 0x0);
736 /* Controller mode sellection */
744 value = (115200/speed)-1;
749 /* FIXME: this can't be right, as it's the same as 115200,
750 * and 576000 is MIR, not SIR. */
763 SetPulseWidth(iobase, 0);
764 SetSendPreambleCount(iobase, 14);
778 /* Set baudrate to 0x19[2..7] */
779 bTmp = (ReadReg(iobase, I_CF_H_1) & 0x03);
781 WriteReg(iobase, I_CF_H_1, bTmp);
783 /* Some dongles may need to be informed about speed changes. */
784 via_ircc_change_dongle_speed(iobase, speed, self->io.dongle_id);
786 /* Set FIFO size to 64 */
790 WriteReg(iobase, I_ST_CT_0, 0x80);
792 // EnTXFIFOHalfLevelInt(iobase,ON);
794 /* Enable some interrupts so we can receive frames */
795 //EnAllInt(iobase,ON);
797 if (IsSIROn(iobase)) {
798 SIRFilter(iobase, ON);
799 SIRRecvAny(iobase, ON);
801 SIRFilter(iobase, OFF);
802 SIRRecvAny(iobase, OFF);
805 if (speed > 115200) {
806 /* Install FIR xmit handler */
807 dev->hard_start_xmit = via_ircc_hard_xmit_fir;
808 via_ircc_dma_receive(self);
810 /* Install SIR xmit handler */
811 dev->hard_start_xmit = via_ircc_hard_xmit_sir;
813 netif_wake_queue(dev);
817 * Function via_ircc_hard_xmit (skb, dev)
819 * Transmit the frame!
822 static int via_ircc_hard_xmit_sir(struct sk_buff *skb,
823 struct net_device *dev)
825 struct via_ircc_cb *self;
830 self = (struct via_ircc_cb *) dev->priv;
831 IRDA_ASSERT(self != NULL, return 0;);
832 iobase = self->io.fir_base;
834 netif_stop_queue(dev);
835 /* Check if we need to change the speed */
836 speed = irda_get_next_speed(skb);
837 if ((speed != self->io.speed) && (speed != -1)) {
838 /* Check for empty frame */
840 via_ircc_change_speed(self, speed);
841 dev->trans_start = jiffies;
845 self->new_speed = speed;
849 SIRFilter(iobase, ON);
853 WriteReg(iobase, I_ST_CT_0, 0x00);
855 spin_lock_irqsave(&self->lock, flags);
856 self->tx_buff.data = self->tx_buff.head;
858 async_wrap_skb(skb, self->tx_buff.data,
859 self->tx_buff.truesize);
861 self->stats.tx_bytes += self->tx_buff.len;
862 /* Send this frame with old speed */
863 SetBaudRate(iobase, self->io.speed);
864 SetPulseWidth(iobase, 12);
865 SetSendPreambleCount(iobase, 0);
866 WriteReg(iobase, I_ST_CT_0, 0x80);
868 EnableTX(iobase, ON);
869 EnableRX(iobase, OFF);
871 ResetChip(iobase, 0);
872 ResetChip(iobase, 1);
873 ResetChip(iobase, 2);
874 ResetChip(iobase, 3);
875 ResetChip(iobase, 4);
877 EnAllInt(iobase, ON);
879 EnRXDMA(iobase, OFF);
881 irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
884 SetSendByte(iobase, self->tx_buff.len);
885 RXStart(iobase, OFF);
888 dev->trans_start = jiffies;
889 spin_unlock_irqrestore(&self->lock, flags);
894 static int via_ircc_hard_xmit_fir(struct sk_buff *skb,
895 struct net_device *dev)
897 struct via_ircc_cb *self;
902 self = (struct via_ircc_cb *) dev->priv;
903 iobase = self->io.fir_base;
905 if (self->st_fifo.len)
907 if (self->chip_id == 0x3076)
911 netif_stop_queue(dev);
912 speed = irda_get_next_speed(skb);
913 if ((speed != self->io.speed) && (speed != -1)) {
915 via_ircc_change_speed(self, speed);
916 dev->trans_start = jiffies;
920 self->new_speed = speed;
922 spin_lock_irqsave(&self->lock, flags);
923 self->tx_fifo.queue[self->tx_fifo.free].start = self->tx_fifo.tail;
924 self->tx_fifo.queue[self->tx_fifo.free].len = skb->len;
926 self->tx_fifo.tail += skb->len;
927 self->stats.tx_bytes += skb->len;
928 skb_copy_from_linear_data(skb,
929 self->tx_fifo.queue[self->tx_fifo.free].start, skb->len);
931 self->tx_fifo.free++;
932 //F01 if (self->tx_fifo.len == 1) {
933 via_ircc_dma_xmit(self, iobase);
935 //F01 if (self->tx_fifo.free < (MAX_TX_WINDOW -1 )) netif_wake_queue(self->netdev);
936 dev->trans_start = jiffies;
938 spin_unlock_irqrestore(&self->lock, flags);
943 static int via_ircc_dma_xmit(struct via_ircc_cb *self, u16 iobase)
945 EnTXDMA(iobase, OFF);
946 self->io.direction = IO_XMIT;
948 EnableTX(iobase, ON);
949 EnableRX(iobase, OFF);
950 ResetChip(iobase, 0);
951 ResetChip(iobase, 1);
952 ResetChip(iobase, 2);
953 ResetChip(iobase, 3);
954 ResetChip(iobase, 4);
955 EnAllInt(iobase, ON);
957 EnRXDMA(iobase, OFF);
958 irda_setup_dma(self->io.dma,
959 ((u8 *)self->tx_fifo.queue[self->tx_fifo.ptr].start -
960 self->tx_buff.head) + self->tx_buff_dma,
961 self->tx_fifo.queue[self->tx_fifo.ptr].len, DMA_TX_MODE);
962 IRDA_DEBUG(1, "%s: tx_fifo.ptr=%x,len=%x,tx_fifo.len=%x..\n",
963 __FUNCTION__, self->tx_fifo.ptr,
964 self->tx_fifo.queue[self->tx_fifo.ptr].len,
967 SetSendByte(iobase, self->tx_fifo.queue[self->tx_fifo.ptr].len);
968 RXStart(iobase, OFF);
975 * Function via_ircc_dma_xmit_complete (self)
977 * The transfer of a frame in finished. This function will only be called
978 * by the interrupt handler
981 static int via_ircc_dma_xmit_complete(struct via_ircc_cb *self)
987 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
989 iobase = self->io.fir_base;
991 // DisableDmaChannel(self->io.dma);
992 /* Check for underrrun! */
993 /* Clear bit, by writing 1 into it */
994 Tx_status = GetTXStatus(iobase);
995 if (Tx_status & 0x08) {
996 self->stats.tx_errors++;
997 self->stats.tx_fifo_errors++;
999 // how to clear underrrun ?
1001 self->stats.tx_packets++;
1002 ResetChip(iobase, 3);
1003 ResetChip(iobase, 4);
1005 /* Check if we need to change the speed */
1006 if (self->new_speed) {
1007 via_ircc_change_speed(self, self->new_speed);
1008 self->new_speed = 0;
1011 /* Finished with this frame, so prepare for next */
1012 if (IsFIROn(iobase)) {
1013 if (self->tx_fifo.len) {
1014 self->tx_fifo.len--;
1015 self->tx_fifo.ptr++;
1019 "%s: tx_fifo.len=%x ,tx_fifo.ptr=%x,tx_fifo.free=%x...\n",
1021 self->tx_fifo.len, self->tx_fifo.ptr, self->tx_fifo.free);
1023 // Any frames to be sent back-to-back?
1024 if (self->tx_fifo.len) {
1025 // Not finished yet!
1026 via_ircc_dma_xmit(self, iobase);
1030 // Reset Tx FIFO info
1031 self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
1032 self->tx_fifo.tail = self->tx_buff.head;
1035 // Make sure we have room for more frames
1036 //F01 if (self->tx_fifo.free < (MAX_TX_WINDOW -1 )) {
1037 // Not busy transmitting anymore
1038 // Tell the network layer, that we can accept more frames
1039 netif_wake_queue(self->netdev);
1045 * Function via_ircc_dma_receive (self)
1047 * Set configuration for receive a frame.
1050 static int via_ircc_dma_receive(struct via_ircc_cb *self)
1054 iobase = self->io.fir_base;
1056 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
1058 self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
1059 self->tx_fifo.tail = self->tx_buff.head;
1060 self->RxDataReady = 0;
1061 self->io.direction = IO_RECV;
1062 self->rx_buff.data = self->rx_buff.head;
1063 self->st_fifo.len = self->st_fifo.pending_bytes = 0;
1064 self->st_fifo.tail = self->st_fifo.head = 0;
1067 EnableTX(iobase, OFF);
1068 EnableRX(iobase, ON);
1070 ResetChip(iobase, 0);
1071 ResetChip(iobase, 1);
1072 ResetChip(iobase, 2);
1073 ResetChip(iobase, 3);
1074 ResetChip(iobase, 4);
1076 EnAllInt(iobase, ON);
1077 EnTXDMA(iobase, OFF);
1078 EnRXDMA(iobase, ON);
1079 irda_setup_dma(self->io.dma2, self->rx_buff_dma,
1080 self->rx_buff.truesize, DMA_RX_MODE);
1081 TXStart(iobase, OFF);
1082 RXStart(iobase, ON);
1088 * Function via_ircc_dma_receive_complete (self)
1090 * Controller Finished with receiving frames,
1091 * and this routine is call by ISR
1094 static int via_ircc_dma_receive_complete(struct via_ircc_cb *self,
1097 struct st_fifo *st_fifo;
1098 struct sk_buff *skb;
1102 iobase = self->io.fir_base;
1103 st_fifo = &self->st_fifo;
1105 if (self->io.speed < 4000000) { //Speed below FIR
1106 len = GetRecvByte(iobase, self);
1107 skb = dev_alloc_skb(len + 1);
1110 // Make sure IP header gets aligned
1111 skb_reserve(skb, 1);
1112 skb_put(skb, len - 2);
1113 if (self->chip_id == 0x3076) {
1114 for (i = 0; i < len - 2; i++)
1115 skb->data[i] = self->rx_buff.data[i * 2];
1117 if (self->chip_id == 0x3096) {
1118 for (i = 0; i < len - 2; i++)
1120 self->rx_buff.data[i];
1123 // Move to next frame
1124 self->rx_buff.data += len;
1125 self->stats.rx_bytes += len;
1126 self->stats.rx_packets++;
1127 skb->dev = self->netdev;
1128 skb_reset_mac_header(skb);
1129 skb->protocol = htons(ETH_P_IRDA);
1135 len = GetRecvByte(iobase, self);
1137 return TRUE; //interrupt only, data maybe move by RxT
1138 if (((len - 4) < 2) || ((len - 4) > 2048)) {
1139 IRDA_DEBUG(1, "%s(): Trouble:len=%x,CurCount=%x,LastCount=%x..\n",
1140 __FUNCTION__, len, RxCurCount(iobase, self),
1145 IRDA_DEBUG(2, "%s(): fifo.len=%x,len=%x,CurCount=%x..\n",
1147 st_fifo->len, len - 4, RxCurCount(iobase, self));
1149 st_fifo->entries[st_fifo->tail].status = status;
1150 st_fifo->entries[st_fifo->tail].len = len;
1151 st_fifo->pending_bytes += len;
1154 if (st_fifo->tail > MAX_RX_WINDOW)
1156 self->RxDataReady = 0;
1158 // It maybe have MAX_RX_WINDOW package receive by
1159 // receive_complete before Timer IRQ
1161 if (st_fifo->len < (MAX_RX_WINDOW+2 )) {
1167 EnableRX(iobase, OFF);
1168 EnRXDMA(iobase, OFF);
1169 RXStart(iobase, OFF);
1171 // Put this entry back in fifo
1172 if (st_fifo->head > MAX_RX_WINDOW)
1174 status = st_fifo->entries[st_fifo->head].status;
1175 len = st_fifo->entries[st_fifo->head].len;
1179 skb = dev_alloc_skb(len + 1 - 4);
1181 * if frame size,data ptr,or skb ptr are wrong ,the get next
1184 if ((skb == NULL) || (skb->data == NULL)
1185 || (self->rx_buff.data == NULL) || (len < 6)) {
1186 self->stats.rx_dropped++;
1189 skb_reserve(skb, 1);
1190 skb_put(skb, len - 4);
1192 skb_copy_to_linear_data(skb, self->rx_buff.data, len - 4);
1193 IRDA_DEBUG(2, "%s(): len=%x.rx_buff=%p\n", __FUNCTION__,
1194 len - 4, self->rx_buff.data);
1196 // Move to next frame
1197 self->rx_buff.data += len;
1198 self->stats.rx_bytes += len;
1199 self->stats.rx_packets++;
1200 skb->dev = self->netdev;
1201 skb_reset_mac_header(skb);
1202 skb->protocol = htons(ETH_P_IRDA);
1212 * if frame is received , but no INT ,then use this routine to upload frame.
1214 static int upload_rxdata(struct via_ircc_cb *self, int iobase)
1216 struct sk_buff *skb;
1218 struct st_fifo *st_fifo;
1219 st_fifo = &self->st_fifo;
1221 len = GetRecvByte(iobase, self);
1223 IRDA_DEBUG(2, "%s(): len=%x\n", __FUNCTION__, len);
1225 if ((len - 4) < 2) {
1226 self->stats.rx_dropped++;
1230 skb = dev_alloc_skb(len + 1);
1232 self->stats.rx_dropped++;
1235 skb_reserve(skb, 1);
1236 skb_put(skb, len - 4 + 1);
1237 skb_copy_to_linear_data(skb, self->rx_buff.data, len - 4 + 1);
1240 if (st_fifo->tail > MAX_RX_WINDOW)
1242 // Move to next frame
1243 self->rx_buff.data += len;
1244 self->stats.rx_bytes += len;
1245 self->stats.rx_packets++;
1246 skb->dev = self->netdev;
1247 skb_reset_mac_header(skb);
1248 skb->protocol = htons(ETH_P_IRDA);
1250 if (st_fifo->len < (MAX_RX_WINDOW + 2)) {
1251 RXStart(iobase, ON);
1253 EnableRX(iobase, OFF);
1254 EnRXDMA(iobase, OFF);
1255 RXStart(iobase, OFF);
1261 * Implement back to back receive , use this routine to upload data.
1264 static int RxTimerHandler(struct via_ircc_cb *self, int iobase)
1266 struct st_fifo *st_fifo;
1267 struct sk_buff *skb;
1271 st_fifo = &self->st_fifo;
1273 if (CkRxRecv(iobase, self)) {
1274 // if still receiving ,then return ,don't upload frame
1275 self->RetryCount = 0;
1276 SetTimer(iobase, 20);
1277 self->RxDataReady++;
1282 if ((self->RetryCount >= 1) ||
1283 ((st_fifo->pending_bytes + 2048) > self->rx_buff.truesize)
1284 || (st_fifo->len >= (MAX_RX_WINDOW))) {
1285 while (st_fifo->len > 0) { //upload frame
1286 // Put this entry back in fifo
1287 if (st_fifo->head > MAX_RX_WINDOW)
1289 status = st_fifo->entries[st_fifo->head].status;
1290 len = st_fifo->entries[st_fifo->head].len;
1294 skb = dev_alloc_skb(len + 1 - 4);
1296 * if frame size, data ptr, or skb ptr are wrong,
1297 * then get next entry.
1299 if ((skb == NULL) || (skb->data == NULL)
1300 || (self->rx_buff.data == NULL) || (len < 6)) {
1301 self->stats.rx_dropped++;
1304 skb_reserve(skb, 1);
1305 skb_put(skb, len - 4);
1306 skb_copy_to_linear_data(skb, self->rx_buff.data, len - 4);
1308 IRDA_DEBUG(2, "%s(): len=%x.head=%x\n", __FUNCTION__,
1309 len - 4, st_fifo->head);
1311 // Move to next frame
1312 self->rx_buff.data += len;
1313 self->stats.rx_bytes += len;
1314 self->stats.rx_packets++;
1315 skb->dev = self->netdev;
1316 skb_reset_mac_header(skb);
1317 skb->protocol = htons(ETH_P_IRDA);
1320 self->RetryCount = 0;
1323 "%s(): End of upload HostStatus=%x,RxStatus=%x\n",
1325 GetHostStatus(iobase), GetRXStatus(iobase));
1328 * if frame is receive complete at this routine ,then upload
1331 if ((GetRXStatus(iobase) & 0x10)
1332 && (RxCurCount(iobase, self) != self->RxLastCount)) {
1333 upload_rxdata(self, iobase);
1334 if (irda_device_txqueue_empty(self->netdev))
1335 via_ircc_dma_receive(self);
1337 } // timer detect complete
1339 SetTimer(iobase, 4);
1347 * Function via_ircc_interrupt (irq, dev_id)
1349 * An interrupt from the chip has arrived. Time to do some work
1352 static irqreturn_t via_ircc_interrupt(int irq, void *dev_id)
1354 struct net_device *dev = (struct net_device *) dev_id;
1355 struct via_ircc_cb *self;
1357 u8 iHostIntType, iRxIntType, iTxIntType;
1360 IRDA_WARNING("%s: irq %d for unknown device.\n", driver_name,
1364 self = (struct via_ircc_cb *) dev->priv;
1365 iobase = self->io.fir_base;
1366 spin_lock(&self->lock);
1367 iHostIntType = GetHostStatus(iobase);
1369 IRDA_DEBUG(4, "%s(): iHostIntType %02x: %s %s %s %02x\n",
1370 __FUNCTION__, iHostIntType,
1371 (iHostIntType & 0x40) ? "Timer" : "",
1372 (iHostIntType & 0x20) ? "Tx" : "",
1373 (iHostIntType & 0x10) ? "Rx" : "",
1374 (iHostIntType & 0x0e) >> 1);
1376 if ((iHostIntType & 0x40) != 0) { //Timer Event
1377 self->EventFlag.TimeOut++;
1378 ClearTimerInt(iobase, 1);
1379 if (self->io.direction == IO_XMIT) {
1380 via_ircc_dma_xmit(self, iobase);
1382 if (self->io.direction == IO_RECV) {
1384 * frame ready hold too long, must reset.
1386 if (self->RxDataReady > 30) {
1388 if (irda_device_txqueue_empty(self->netdev)) {
1389 via_ircc_dma_receive(self);
1391 } else { // call this to upload frame.
1392 RxTimerHandler(self, iobase);
1396 if ((iHostIntType & 0x20) != 0) { //Tx Event
1397 iTxIntType = GetTXStatus(iobase);
1399 IRDA_DEBUG(4, "%s(): iTxIntType %02x: %s %s %s %s\n",
1400 __FUNCTION__, iTxIntType,
1401 (iTxIntType & 0x08) ? "FIFO underr." : "",
1402 (iTxIntType & 0x04) ? "EOM" : "",
1403 (iTxIntType & 0x02) ? "FIFO ready" : "",
1404 (iTxIntType & 0x01) ? "Early EOM" : "");
1406 if (iTxIntType & 0x4) {
1407 self->EventFlag.EOMessage++; // read and will auto clean
1408 if (via_ircc_dma_xmit_complete(self)) {
1409 if (irda_device_txqueue_empty
1411 via_ircc_dma_receive(self);
1414 self->EventFlag.Unknown++;
1418 //----------------------------------------
1419 if ((iHostIntType & 0x10) != 0) { //Rx Event
1420 /* Check if DMA has finished */
1421 iRxIntType = GetRXStatus(iobase);
1423 IRDA_DEBUG(4, "%s(): iRxIntType %02x: %s %s %s %s %s %s %s\n",
1424 __FUNCTION__, iRxIntType,
1425 (iRxIntType & 0x80) ? "PHY err." : "",
1426 (iRxIntType & 0x40) ? "CRC err" : "",
1427 (iRxIntType & 0x20) ? "FIFO overr." : "",
1428 (iRxIntType & 0x10) ? "EOF" : "",
1429 (iRxIntType & 0x08) ? "RxData" : "",
1430 (iRxIntType & 0x02) ? "RxMaxLen" : "",
1431 (iRxIntType & 0x01) ? "SIR bad" : "");
1433 IRDA_DEBUG(3, "%s(): RxIRQ =0\n", __FUNCTION__);
1435 if (iRxIntType & 0x10) {
1436 if (via_ircc_dma_receive_complete(self, iobase)) {
1437 //F01 if(!(IsFIROn(iobase))) via_ircc_dma_receive(self);
1438 via_ircc_dma_receive(self);
1442 IRDA_DEBUG(4, "%s(): RxIRQ ERR:iRxIntType=%x,HostIntType=%x,CurCount=%x,RxLastCount=%x_____\n",
1443 __FUNCTION__, iRxIntType, iHostIntType,
1444 RxCurCount(iobase, self),
1447 if (iRxIntType & 0x20) { //FIFO OverRun ERR
1448 ResetChip(iobase, 0);
1449 ResetChip(iobase, 1);
1450 } else { //PHY,CRC ERR
1452 if (iRxIntType != 0x08)
1453 hwreset(self); //F01
1455 via_ircc_dma_receive(self);
1459 spin_unlock(&self->lock);
1460 return IRQ_RETVAL(iHostIntType);
1463 static void hwreset(struct via_ircc_cb *self)
1466 iobase = self->io.fir_base;
1468 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
1470 ResetChip(iobase, 5);
1471 EnableDMA(iobase, OFF);
1472 EnableTX(iobase, OFF);
1473 EnableRX(iobase, OFF);
1474 EnRXDMA(iobase, OFF);
1475 EnTXDMA(iobase, OFF);
1476 RXStart(iobase, OFF);
1477 TXStart(iobase, OFF);
1480 SIRFilter(iobase, ON);
1484 WriteReg(iobase, I_ST_CT_0, 0x00);
1485 SetBaudRate(iobase, 9600);
1486 SetPulseWidth(iobase, 12);
1487 SetSendPreambleCount(iobase, 0);
1488 WriteReg(iobase, I_ST_CT_0, 0x80);
1490 /* Restore speed. */
1491 via_ircc_change_speed(self, self->io.speed);
1493 self->st_fifo.len = 0;
1497 * Function via_ircc_is_receiving (self)
1499 * Return TRUE is we are currently receiving a frame
1502 static int via_ircc_is_receiving(struct via_ircc_cb *self)
1507 IRDA_ASSERT(self != NULL, return FALSE;);
1509 iobase = self->io.fir_base;
1510 if (CkRxRecv(iobase, self))
1513 IRDA_DEBUG(2, "%s(): status=%x....\n", __FUNCTION__, status);
1520 * Function via_ircc_net_open (dev)
1525 static int via_ircc_net_open(struct net_device *dev)
1527 struct via_ircc_cb *self;
1531 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
1533 IRDA_ASSERT(dev != NULL, return -1;);
1534 self = (struct via_ircc_cb *) dev->priv;
1535 self->stats.rx_packets = 0;
1536 IRDA_ASSERT(self != NULL, return 0;);
1537 iobase = self->io.fir_base;
1538 if (request_irq(self->io.irq, via_ircc_interrupt, 0, dev->name, dev)) {
1539 IRDA_WARNING("%s, unable to allocate irq=%d\n", driver_name,
1544 * Always allocate the DMA channel after the IRQ, and clean up on
1547 if (request_dma(self->io.dma, dev->name)) {
1548 IRDA_WARNING("%s, unable to allocate dma=%d\n", driver_name,
1550 free_irq(self->io.irq, self);
1553 if (self->io.dma2 != self->io.dma) {
1554 if (request_dma(self->io.dma2, dev->name)) {
1555 IRDA_WARNING("%s, unable to allocate dma2=%d\n",
1556 driver_name, self->io.dma2);
1557 free_irq(self->io.irq, self);
1563 /* turn on interrupts */
1564 EnAllInt(iobase, ON);
1565 EnInternalLoop(iobase, OFF);
1566 EnExternalLoop(iobase, OFF);
1569 via_ircc_dma_receive(self);
1571 /* Ready to play! */
1572 netif_start_queue(dev);
1575 * Open new IrLAP layer instance, now that everything should be
1576 * initialized properly
1578 sprintf(hwname, "VIA @ 0x%x", iobase);
1579 self->irlap = irlap_open(dev, &self->qos, hwname);
1581 self->RxLastCount = 0;
1587 * Function via_ircc_net_close (dev)
1592 static int via_ircc_net_close(struct net_device *dev)
1594 struct via_ircc_cb *self;
1597 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
1599 IRDA_ASSERT(dev != NULL, return -1;);
1600 self = (struct via_ircc_cb *) dev->priv;
1601 IRDA_ASSERT(self != NULL, return 0;);
1604 netif_stop_queue(dev);
1605 /* Stop and remove instance of IrLAP */
1607 irlap_close(self->irlap);
1609 iobase = self->io.fir_base;
1610 EnTXDMA(iobase, OFF);
1611 EnRXDMA(iobase, OFF);
1612 DisableDmaChannel(self->io.dma);
1614 /* Disable interrupts */
1615 EnAllInt(iobase, OFF);
1616 free_irq(self->io.irq, dev);
1617 free_dma(self->io.dma);
1623 * Function via_ircc_net_ioctl (dev, rq, cmd)
1625 * Process IOCTL commands for this device
1628 static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq,
1631 struct if_irda_req *irq = (struct if_irda_req *) rq;
1632 struct via_ircc_cb *self;
1633 unsigned long flags;
1636 IRDA_ASSERT(dev != NULL, return -1;);
1638 IRDA_ASSERT(self != NULL, return -1;);
1639 IRDA_DEBUG(1, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name,
1641 /* Disable interrupts & save flags */
1642 spin_lock_irqsave(&self->lock, flags);
1644 case SIOCSBANDWIDTH: /* Set bandwidth */
1645 if (!capable(CAP_NET_ADMIN)) {
1649 via_ircc_change_speed(self, irq->ifr_baudrate);
1651 case SIOCSMEDIABUSY: /* Set media busy */
1652 if (!capable(CAP_NET_ADMIN)) {
1656 irda_device_set_media_busy(self->netdev, TRUE);
1658 case SIOCGRECEIVING: /* Check if we are receiving right now */
1659 irq->ifr_receiving = via_ircc_is_receiving(self);
1665 spin_unlock_irqrestore(&self->lock, flags);
1669 static struct net_device_stats *via_ircc_net_get_stats(struct net_device
1672 struct via_ircc_cb *self = (struct via_ircc_cb *) dev->priv;
1674 return &self->stats;
1677 MODULE_AUTHOR("VIA Technologies,inc");
1678 MODULE_DESCRIPTION("VIA IrDA Device Driver");
1679 MODULE_LICENSE("GPL");
1681 module_init(via_ircc_init);
1682 module_exit(via_ircc_cleanup);