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 struct pt_regs *regs);
98 static int via_ircc_is_receiving(struct via_ircc_cb *self);
99 static int via_ircc_read_dongle_id(int iobase);
101 static int via_ircc_net_open(struct net_device *dev);
102 static int via_ircc_net_close(struct net_device *dev);
103 static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq,
105 static struct net_device_stats *via_ircc_net_get_stats(struct net_device
107 static void via_ircc_change_dongle_speed(int iobase, int speed,
109 static int RxTimerHandler(struct via_ircc_cb *self, int iobase);
110 static void hwreset(struct via_ircc_cb *self);
111 static int via_ircc_dma_xmit(struct via_ircc_cb *self, u16 iobase);
112 static int upload_rxdata(struct via_ircc_cb *self, int iobase);
113 static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_device_id *id);
114 static void __devexit via_remove_one (struct pci_dev *pdev);
116 /* FIXME : Should use udelay() instead, even if we are x86 only - Jean II */
117 static void iodelay(int udelay)
122 for (i = 0; i < udelay; i++) {
127 static struct pci_device_id via_pci_tbl[] = {
128 { PCI_VENDOR_ID_VIA, 0x8231, PCI_ANY_ID, PCI_ANY_ID,0,0,0 },
129 { PCI_VENDOR_ID_VIA, 0x3109, PCI_ANY_ID, PCI_ANY_ID,0,0,1 },
130 { PCI_VENDOR_ID_VIA, 0x3074, PCI_ANY_ID, PCI_ANY_ID,0,0,2 },
131 { PCI_VENDOR_ID_VIA, 0x3147, PCI_ANY_ID, PCI_ANY_ID,0,0,3 },
132 { PCI_VENDOR_ID_VIA, 0x3177, PCI_ANY_ID, PCI_ANY_ID,0,0,4 },
136 MODULE_DEVICE_TABLE(pci,via_pci_tbl);
139 static struct pci_driver via_driver = {
140 .name = VIA_MODULE_NAME,
141 .id_table = via_pci_tbl,
142 .probe = via_init_one,
143 .remove = __devexit_p(via_remove_one),
148 * Function via_ircc_init ()
150 * Initialize chip. Just find out chip type and resource.
152 static int __init via_ircc_init(void)
156 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
158 rc = pci_register_driver(&via_driver);
160 IRDA_DEBUG(0, "%s(): error rc = %d, returning -ENODEV...\n",
167 static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_device_id *id)
170 u8 temp,oldPCI_40,oldPCI_44,bTmp,bTmp1;
171 u16 Chipset,FirDRQ1,FirDRQ0,FirIRQ,FirIOBase;
174 IRDA_DEBUG(2, "%s(): Device ID=(0X%X)\n", __FUNCTION__, id->device);
176 rc = pci_enable_device (pcidev);
178 IRDA_DEBUG(0, "%s(): error rc = %d\n", __FUNCTION__, rc);
182 // South Bridge exist
183 if ( ReadLPCReg(0x20) != 0x3C )
188 if (Chipset==0x3076) {
189 IRDA_DEBUG(2, "%s(): Chipset = 3076\n", __FUNCTION__);
191 WriteLPCReg(7,0x0c );
192 temp=ReadLPCReg(0x30);//check if BIOS Enable Fir
193 if((temp&0x01)==1) { // BIOS close or no FIR
194 WriteLPCReg(0x1d, 0x82 );
195 WriteLPCReg(0x23,0x18);
196 temp=ReadLPCReg(0xF0);
198 temp=(ReadLPCReg(0x74)&0x03); //DMA
200 temp=(ReadLPCReg(0x74)&0x0C) >> 2;
203 temp=(ReadLPCReg(0x74)&0x0C) >> 2; //DMA
207 FirIRQ=(ReadLPCReg(0x70)&0x0f); //IRQ
208 FirIOBase=ReadLPCReg(0x60 ) << 8; //IO Space :high byte
209 FirIOBase=FirIOBase| ReadLPCReg(0x61) ; //low byte
210 FirIOBase=FirIOBase ;
211 info.fir_base=FirIOBase;
215 pci_read_config_byte(pcidev,0x40,&bTmp);
216 pci_write_config_byte(pcidev,0x40,((bTmp | 0x08) & 0xfe));
217 pci_read_config_byte(pcidev,0x42,&bTmp);
218 pci_write_config_byte(pcidev,0x42,(bTmp | 0xf0));
219 pci_write_config_byte(pcidev,0x5a,0xc0);
220 WriteLPCReg(0x28, 0x70 );
221 if (via_ircc_open(0, &info,0x3076) == 0)
224 rc = -ENODEV; //IR not turn on
225 } else { //Not VT1211
226 IRDA_DEBUG(2, "%s(): Chipset = 3096\n", __FUNCTION__);
228 pci_read_config_byte(pcidev,0x67,&bTmp);//check if BIOS Enable Fir
229 if((bTmp&0x01)==1) { // BIOS enable FIR
230 //Enable Double DMA clock
231 pci_read_config_byte(pcidev,0x42,&oldPCI_40);
232 pci_write_config_byte(pcidev,0x42,oldPCI_40 | 0x80);
233 pci_read_config_byte(pcidev,0x40,&oldPCI_40);
234 pci_write_config_byte(pcidev,0x40,oldPCI_40 & 0xf7);
235 pci_read_config_byte(pcidev,0x44,&oldPCI_44);
236 pci_write_config_byte(pcidev,0x44,0x4e);
237 //---------- read configuration from Function0 of south bridge
239 pci_read_config_byte(pcidev,0x44,&bTmp1); //DMA
240 FirDRQ0 = (bTmp1 & 0x30) >> 4;
241 pci_read_config_byte(pcidev,0x44,&bTmp1);
242 FirDRQ1 = (bTmp1 & 0xc0) >> 6;
244 pci_read_config_byte(pcidev,0x44,&bTmp1); //DMA
245 FirDRQ0 = (bTmp1 & 0x30) >> 4 ;
248 pci_read_config_byte(pcidev,0x47,&bTmp1); //IRQ
249 FirIRQ = bTmp1 & 0x0f;
251 pci_read_config_byte(pcidev,0x69,&bTmp);
252 FirIOBase = bTmp << 8;//hight byte
253 pci_read_config_byte(pcidev,0x68,&bTmp);
254 FirIOBase = (FirIOBase | bTmp ) & 0xfff0;
255 //-------------------------
256 info.fir_base=FirIOBase;
260 if (via_ircc_open(0, &info,0x3096) == 0)
263 rc = -ENODEV; //IR not turn on !!!!!
266 IRDA_DEBUG(2, "%s(): End - rc = %d\n", __FUNCTION__, rc);
271 * Function via_ircc_clean ()
273 * Close all configured chips
276 static void via_ircc_clean(void)
280 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
282 for (i=0; i < ARRAY_SIZE(dev_self); i++) {
284 via_ircc_close(dev_self[i]);
288 static void __devexit via_remove_one (struct pci_dev *pdev)
290 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
292 /* FIXME : This is ugly. We should use pci_get_drvdata(pdev);
293 * to get our driver instance and call directly via_ircc_close().
294 * See vlsi_ir for details...
298 /* FIXME : This should be in via_ircc_close(), because here we may
299 * theoritically disable still configured devices :-( - Jean II */
300 pci_disable_device(pdev);
303 static void __exit via_ircc_cleanup(void)
305 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
307 /* FIXME : This should be redundant, as pci_unregister_driver()
308 * should call via_remove_one() on each device.
312 /* Cleanup all instances of the driver */
313 pci_unregister_driver (&via_driver);
317 * Function via_ircc_open (iobase, irq)
319 * Open driver instance
322 static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
324 struct net_device *dev;
325 struct via_ircc_cb *self;
328 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
330 if (i >= ARRAY_SIZE(dev_self))
333 /* Allocate new instance of the driver */
334 dev = alloc_irdadev(sizeof(struct via_ircc_cb));
340 spin_lock_init(&self->lock);
342 /* FIXME : We should store our driver instance in the PCI layer,
343 * using pci_set_drvdata(), not in this array.
344 * See vlsi_ir for details... - Jean II */
345 /* FIXME : 'i' is always 0 (see via_init_one()) :-( - Jean II */
346 /* Need to store self somewhere */
349 /* Initialize Resource */
350 self->io.cfg_base = info->cfg_base;
351 self->io.fir_base = info->fir_base;
352 self->io.irq = info->irq;
353 self->io.fir_ext = CHIP_IO_EXTENT;
354 self->io.dma = info->dma;
355 self->io.dma2 = info->dma2;
356 self->io.fifo_size = 32;
358 self->st_fifo.len = 0;
359 self->RxDataReady = 0;
361 /* Reserve the ioports that we need */
362 if (!request_region(self->io.fir_base, self->io.fir_ext, driver_name)) {
363 IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n",
364 __FUNCTION__, self->io.fir_base);
369 /* Initialize QoS for this device */
370 irda_init_max_qos_capabilies(&self->qos);
372 /* Check if user has supplied the dongle id or not */
374 dongle_id = via_ircc_read_dongle_id(self->io.fir_base);
375 self->io.dongle_id = dongle_id;
377 /* The only value we must override it the baudrate */
378 /* Maximum speeds and capabilities are dongle-dependant. */
379 switch( self->io.dongle_id ){
381 self->qos.baud_rate.bits =
382 IR_9600 | IR_19200 | IR_38400 | IR_57600 | IR_115200 |
383 IR_576000 | IR_1152000 | (IR_4000000 << 8);
386 self->qos.baud_rate.bits =
387 IR_9600 | IR_19200 | IR_38400 | IR_57600 | IR_115200;
391 /* Following was used for testing:
393 * self->qos.baud_rate.bits = IR_9600;
395 * Is is no good, as it prohibits (error-prone) speed-changes.
398 self->qos.min_turn_time.bits = qos_mtt_bits;
399 irda_qos_bits_to_value(&self->qos);
401 /* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */
402 self->rx_buff.truesize = 14384 + 2048;
403 self->tx_buff.truesize = 14384 + 2048;
405 /* Allocate memory if needed */
407 dma_alloc_coherent(NULL, self->rx_buff.truesize,
408 &self->rx_buff_dma, GFP_KERNEL);
409 if (self->rx_buff.head == NULL) {
413 memset(self->rx_buff.head, 0, self->rx_buff.truesize);
416 dma_alloc_coherent(NULL, self->tx_buff.truesize,
417 &self->tx_buff_dma, GFP_KERNEL);
418 if (self->tx_buff.head == NULL) {
422 memset(self->tx_buff.head, 0, self->tx_buff.truesize);
424 self->rx_buff.in_frame = FALSE;
425 self->rx_buff.state = OUTSIDE_FRAME;
426 self->tx_buff.data = self->tx_buff.head;
427 self->rx_buff.data = self->rx_buff.head;
429 /* Reset Tx queue info */
430 self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
431 self->tx_fifo.tail = self->tx_buff.head;
433 /* Keep track of module usage */
434 SET_MODULE_OWNER(dev);
436 /* Override the network functions we need to use */
437 dev->hard_start_xmit = via_ircc_hard_xmit_sir;
438 dev->open = via_ircc_net_open;
439 dev->stop = via_ircc_net_close;
440 dev->do_ioctl = via_ircc_net_ioctl;
441 dev->get_stats = via_ircc_net_get_stats;
443 err = register_netdev(dev);
447 IRDA_MESSAGE("IrDA: Registered device %s (via-ircc)\n", dev->name);
449 /* Initialise the hardware..
451 self->io.speed = 9600;
455 dma_free_coherent(NULL, self->tx_buff.truesize,
456 self->tx_buff.head, self->tx_buff_dma);
458 dma_free_coherent(NULL, self->rx_buff.truesize,
459 self->rx_buff.head, self->rx_buff_dma);
461 release_region(self->io.fir_base, self->io.fir_ext);
469 * Function via_ircc_close (self)
471 * Close driver instance
474 static int via_ircc_close(struct via_ircc_cb *self)
478 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
480 IRDA_ASSERT(self != NULL, return -1;);
482 iobase = self->io.fir_base;
484 ResetChip(iobase, 5); //hardware reset.
485 /* Remove netdevice */
486 unregister_netdev(self->netdev);
488 /* Release the PORT that this driver is using */
489 IRDA_DEBUG(2, "%s(), Releasing Region %03x\n",
490 __FUNCTION__, self->io.fir_base);
491 release_region(self->io.fir_base, self->io.fir_ext);
492 if (self->tx_buff.head)
493 dma_free_coherent(NULL, self->tx_buff.truesize,
494 self->tx_buff.head, self->tx_buff_dma);
495 if (self->rx_buff.head)
496 dma_free_coherent(NULL, self->rx_buff.truesize,
497 self->rx_buff.head, self->rx_buff_dma);
498 dev_self[self->index] = NULL;
500 free_netdev(self->netdev);
506 * Function via_hw_init(self)
508 * Returns non-negative on success.
510 * Formerly via_ircc_setup
512 static void via_hw_init(struct via_ircc_cb *self)
514 int iobase = self->io.fir_base;
516 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
518 SetMaxRxPacketSize(iobase, 0x0fff); //set to max:4095
520 EnRXFIFOReadyInt(iobase, OFF);
521 EnRXFIFOHalfLevelInt(iobase, OFF);
522 EnTXFIFOHalfLevelInt(iobase, OFF);
523 EnTXFIFOUnderrunEOMInt(iobase, ON);
524 EnTXFIFOReadyInt(iobase, OFF);
525 InvertTX(iobase, OFF);
526 InvertRX(iobase, OFF);
528 if (ReadLPCReg(0x20) == 0x3c)
529 WriteLPCReg(0xF0, 0); // for VT1211
531 EnRXSpecInt(iobase, ON);
533 /* The following is basically hwreset */
534 /* If this is the case, why not just call hwreset() ? Jean II */
535 ResetChip(iobase, 5);
536 EnableDMA(iobase, OFF);
537 EnableTX(iobase, OFF);
538 EnableRX(iobase, OFF);
539 EnRXDMA(iobase, OFF);
540 EnTXDMA(iobase, OFF);
541 RXStart(iobase, OFF);
542 TXStart(iobase, OFF);
545 SIRFilter(iobase, ON);
549 WriteReg(iobase, I_ST_CT_0, 0x00);
550 SetBaudRate(iobase, 9600);
551 SetPulseWidth(iobase, 12);
552 SetSendPreambleCount(iobase, 0);
554 self->io.speed = 9600;
555 self->st_fifo.len = 0;
557 via_ircc_change_dongle_speed(iobase, self->io.speed,
560 WriteReg(iobase, I_ST_CT_0, 0x80);
564 * Function via_ircc_read_dongle_id (void)
567 static int via_ircc_read_dongle_id(int iobase)
569 int dongle_id = 9; /* Default to IBM */
571 IRDA_ERROR("via-ircc: dongle probing not supported, please specify dongle_id module parameter.\n");
576 * Function via_ircc_change_dongle_speed (iobase, speed, dongle_id)
577 * Change speed of the attach dongle
578 * only implement two type of dongle currently.
580 static void via_ircc_change_dongle_speed(int iobase, int speed,
585 /* speed is unused, as we use IsSIROn()/IsMIROn() */
588 IRDA_DEBUG(1, "%s(): change_dongle_speed to %d for 0x%x, %d\n",
589 __FUNCTION__, speed, iobase, dongle_id);
593 /* Note: The dongle_id's listed here are derived from
596 case 0x08: /* HP HSDL-2300, HP HSDL-3600/HSDL-3610 */
597 UseOneRX(iobase, ON); // use one RX pin RX1,RX2
598 InvertTX(iobase, OFF);
599 InvertRX(iobase, OFF);
601 EnRX2(iobase, ON); //sir to rx2
602 EnGPIOtoRX2(iobase, OFF);
604 if (IsSIROn(iobase)) { //sir
606 SlowIRRXLowActive(iobase, ON);
608 SlowIRRXLowActive(iobase, OFF);
610 if (IsMIROn(iobase)) { //mir
612 SlowIRRXLowActive(iobase, OFF);
615 if (IsFIROn(iobase)) { //fir
617 SlowIRRXLowActive(iobase, OFF);
624 case 0x09: /* IBM31T1100 or Temic TFDS6000/TFDS6500 */
625 UseOneRX(iobase, ON); //use ONE RX....RX1
626 InvertTX(iobase, OFF);
627 InvertRX(iobase, OFF); // invert RX pin
630 EnGPIOtoRX2(iobase, OFF);
631 if (IsSIROn(iobase)) { //sir
633 SlowIRRXLowActive(iobase, ON);
636 SlowIRRXLowActive(iobase, OFF);
638 if (IsMIROn(iobase)) { //mir
640 SlowIRRXLowActive(iobase, OFF);
643 SlowIRRXLowActive(iobase, ON);
645 if (IsFIROn(iobase)) { //fir
647 SlowIRRXLowActive(iobase, OFF);
652 SlowIRRXLowActive(iobase, ON);
655 WriteTX(iobase, OFF);
661 UseOneRX(iobase, OFF); // use two RX pin RX1,RX2
662 InvertTX(iobase, OFF);
663 InvertRX(iobase, OFF);
664 SlowIRRXLowActive(iobase, OFF);
665 if (IsSIROn(iobase)) { //sir
666 EnGPIOtoRX2(iobase, OFF);
667 WriteGIO(iobase, OFF);
668 EnRX2(iobase, OFF); //sir to rx2
670 EnGPIOtoRX2(iobase, OFF);
671 WriteGIO(iobase, OFF);
672 EnRX2(iobase, OFF); //fir to rx
676 case 0x11: /* Temic TFDS4500 */
678 IRDA_DEBUG(2, "%s: Temic TFDS4500: One RX pin, TX normal, RX inverted.\n", __FUNCTION__);
680 UseOneRX(iobase, ON); //use ONE RX....RX1
681 InvertTX(iobase, OFF);
682 InvertRX(iobase, ON); // invert RX pin
684 EnRX2(iobase, ON); //sir to rx2
685 EnGPIOtoRX2(iobase, OFF);
687 if( IsSIROn(iobase) ){ //sir
690 SlowIRRXLowActive(iobase, ON);
693 SlowIRRXLowActive(iobase, OFF);
696 IRDA_DEBUG(0, "%s: Warning: TFDS4500 not running in SIR mode !\n", __FUNCTION__);
700 case 0x0ff: /* Vishay */
703 else if (IsMIROn(iobase))
705 else if (IsFIROn(iobase))
707 else if (IsVFIROn(iobase))
709 SI_SetMode(iobase, mode);
713 IRDA_ERROR("%s: Error: dongle_id %d unsupported !\n",
714 __FUNCTION__, dongle_id);
719 * Function via_ircc_change_speed (self, baud)
721 * Change the speed of the device
724 static void via_ircc_change_speed(struct via_ircc_cb *self, __u32 speed)
726 struct net_device *dev = self->netdev;
730 iobase = self->io.fir_base;
731 /* Update accounting for new speed */
732 self->io.speed = speed;
733 IRDA_DEBUG(1, "%s: change_speed to %d bps.\n", __FUNCTION__, speed);
735 WriteReg(iobase, I_ST_CT_0, 0x0);
737 /* Controller mode sellection */
745 value = (115200/speed)-1;
750 /* FIXME: this can't be right, as it's the same as 115200,
751 * and 576000 is MIR, not SIR. */
764 SetPulseWidth(iobase, 0);
765 SetSendPreambleCount(iobase, 14);
779 /* Set baudrate to 0x19[2..7] */
780 bTmp = (ReadReg(iobase, I_CF_H_1) & 0x03);
782 WriteReg(iobase, I_CF_H_1, bTmp);
784 /* Some dongles may need to be informed about speed changes. */
785 via_ircc_change_dongle_speed(iobase, speed, self->io.dongle_id);
787 /* Set FIFO size to 64 */
791 WriteReg(iobase, I_ST_CT_0, 0x80);
793 // EnTXFIFOHalfLevelInt(iobase,ON);
795 /* Enable some interrupts so we can receive frames */
796 //EnAllInt(iobase,ON);
798 if (IsSIROn(iobase)) {
799 SIRFilter(iobase, ON);
800 SIRRecvAny(iobase, ON);
802 SIRFilter(iobase, OFF);
803 SIRRecvAny(iobase, OFF);
806 if (speed > 115200) {
807 /* Install FIR xmit handler */
808 dev->hard_start_xmit = via_ircc_hard_xmit_fir;
809 via_ircc_dma_receive(self);
811 /* Install SIR xmit handler */
812 dev->hard_start_xmit = via_ircc_hard_xmit_sir;
814 netif_wake_queue(dev);
818 * Function via_ircc_hard_xmit (skb, dev)
820 * Transmit the frame!
823 static int via_ircc_hard_xmit_sir(struct sk_buff *skb,
824 struct net_device *dev)
826 struct via_ircc_cb *self;
831 self = (struct via_ircc_cb *) dev->priv;
832 IRDA_ASSERT(self != NULL, return 0;);
833 iobase = self->io.fir_base;
835 netif_stop_queue(dev);
836 /* Check if we need to change the speed */
837 speed = irda_get_next_speed(skb);
838 if ((speed != self->io.speed) && (speed != -1)) {
839 /* Check for empty frame */
841 via_ircc_change_speed(self, speed);
842 dev->trans_start = jiffies;
846 self->new_speed = speed;
850 SIRFilter(iobase, ON);
854 WriteReg(iobase, I_ST_CT_0, 0x00);
856 spin_lock_irqsave(&self->lock, flags);
857 self->tx_buff.data = self->tx_buff.head;
859 async_wrap_skb(skb, self->tx_buff.data,
860 self->tx_buff.truesize);
862 self->stats.tx_bytes += self->tx_buff.len;
863 /* Send this frame with old speed */
864 SetBaudRate(iobase, self->io.speed);
865 SetPulseWidth(iobase, 12);
866 SetSendPreambleCount(iobase, 0);
867 WriteReg(iobase, I_ST_CT_0, 0x80);
869 EnableTX(iobase, ON);
870 EnableRX(iobase, OFF);
872 ResetChip(iobase, 0);
873 ResetChip(iobase, 1);
874 ResetChip(iobase, 2);
875 ResetChip(iobase, 3);
876 ResetChip(iobase, 4);
878 EnAllInt(iobase, ON);
880 EnRXDMA(iobase, OFF);
882 irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
885 SetSendByte(iobase, self->tx_buff.len);
886 RXStart(iobase, OFF);
889 dev->trans_start = jiffies;
890 spin_unlock_irqrestore(&self->lock, flags);
895 static int via_ircc_hard_xmit_fir(struct sk_buff *skb,
896 struct net_device *dev)
898 struct via_ircc_cb *self;
903 self = (struct via_ircc_cb *) dev->priv;
904 iobase = self->io.fir_base;
906 if (self->st_fifo.len)
908 if (self->chip_id == 0x3076)
912 netif_stop_queue(dev);
913 speed = irda_get_next_speed(skb);
914 if ((speed != self->io.speed) && (speed != -1)) {
916 via_ircc_change_speed(self, speed);
917 dev->trans_start = jiffies;
921 self->new_speed = speed;
923 spin_lock_irqsave(&self->lock, flags);
924 self->tx_fifo.queue[self->tx_fifo.free].start = self->tx_fifo.tail;
925 self->tx_fifo.queue[self->tx_fifo.free].len = skb->len;
927 self->tx_fifo.tail += skb->len;
928 self->stats.tx_bytes += skb->len;
929 memcpy(self->tx_fifo.queue[self->tx_fifo.free].start, skb->data,
932 self->tx_fifo.free++;
933 //F01 if (self->tx_fifo.len == 1) {
934 via_ircc_dma_xmit(self, iobase);
936 //F01 if (self->tx_fifo.free < (MAX_TX_WINDOW -1 )) netif_wake_queue(self->netdev);
937 dev->trans_start = jiffies;
939 spin_unlock_irqrestore(&self->lock, flags);
944 static int via_ircc_dma_xmit(struct via_ircc_cb *self, u16 iobase)
946 EnTXDMA(iobase, OFF);
947 self->io.direction = IO_XMIT;
949 EnableTX(iobase, ON);
950 EnableRX(iobase, OFF);
951 ResetChip(iobase, 0);
952 ResetChip(iobase, 1);
953 ResetChip(iobase, 2);
954 ResetChip(iobase, 3);
955 ResetChip(iobase, 4);
956 EnAllInt(iobase, ON);
958 EnRXDMA(iobase, OFF);
959 irda_setup_dma(self->io.dma,
960 ((u8 *)self->tx_fifo.queue[self->tx_fifo.ptr].start -
961 self->tx_buff.head) + self->tx_buff_dma,
962 self->tx_fifo.queue[self->tx_fifo.ptr].len, DMA_TX_MODE);
963 IRDA_DEBUG(1, "%s: tx_fifo.ptr=%x,len=%x,tx_fifo.len=%x..\n",
964 __FUNCTION__, self->tx_fifo.ptr,
965 self->tx_fifo.queue[self->tx_fifo.ptr].len,
968 SetSendByte(iobase, self->tx_fifo.queue[self->tx_fifo.ptr].len);
969 RXStart(iobase, OFF);
976 * Function via_ircc_dma_xmit_complete (self)
978 * The transfer of a frame in finished. This function will only be called
979 * by the interrupt handler
982 static int via_ircc_dma_xmit_complete(struct via_ircc_cb *self)
988 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
990 iobase = self->io.fir_base;
992 // DisableDmaChannel(self->io.dma);
993 /* Check for underrrun! */
994 /* Clear bit, by writing 1 into it */
995 Tx_status = GetTXStatus(iobase);
996 if (Tx_status & 0x08) {
997 self->stats.tx_errors++;
998 self->stats.tx_fifo_errors++;
1000 // how to clear underrrun ?
1002 self->stats.tx_packets++;
1003 ResetChip(iobase, 3);
1004 ResetChip(iobase, 4);
1006 /* Check if we need to change the speed */
1007 if (self->new_speed) {
1008 via_ircc_change_speed(self, self->new_speed);
1009 self->new_speed = 0;
1012 /* Finished with this frame, so prepare for next */
1013 if (IsFIROn(iobase)) {
1014 if (self->tx_fifo.len) {
1015 self->tx_fifo.len--;
1016 self->tx_fifo.ptr++;
1020 "%s: tx_fifo.len=%x ,tx_fifo.ptr=%x,tx_fifo.free=%x...\n",
1022 self->tx_fifo.len, self->tx_fifo.ptr, self->tx_fifo.free);
1024 // Any frames to be sent back-to-back?
1025 if (self->tx_fifo.len) {
1026 // Not finished yet!
1027 via_ircc_dma_xmit(self, iobase);
1031 // Reset Tx FIFO info
1032 self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
1033 self->tx_fifo.tail = self->tx_buff.head;
1036 // Make sure we have room for more frames
1037 //F01 if (self->tx_fifo.free < (MAX_TX_WINDOW -1 )) {
1038 // Not busy transmitting anymore
1039 // Tell the network layer, that we can accept more frames
1040 netif_wake_queue(self->netdev);
1046 * Function via_ircc_dma_receive (self)
1048 * Set configuration for receive a frame.
1051 static int via_ircc_dma_receive(struct via_ircc_cb *self)
1055 iobase = self->io.fir_base;
1057 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
1059 self->tx_fifo.len = self->tx_fifo.ptr = self->tx_fifo.free = 0;
1060 self->tx_fifo.tail = self->tx_buff.head;
1061 self->RxDataReady = 0;
1062 self->io.direction = IO_RECV;
1063 self->rx_buff.data = self->rx_buff.head;
1064 self->st_fifo.len = self->st_fifo.pending_bytes = 0;
1065 self->st_fifo.tail = self->st_fifo.head = 0;
1068 EnableTX(iobase, OFF);
1069 EnableRX(iobase, ON);
1071 ResetChip(iobase, 0);
1072 ResetChip(iobase, 1);
1073 ResetChip(iobase, 2);
1074 ResetChip(iobase, 3);
1075 ResetChip(iobase, 4);
1077 EnAllInt(iobase, ON);
1078 EnTXDMA(iobase, OFF);
1079 EnRXDMA(iobase, ON);
1080 irda_setup_dma(self->io.dma2, self->rx_buff_dma,
1081 self->rx_buff.truesize, DMA_RX_MODE);
1082 TXStart(iobase, OFF);
1083 RXStart(iobase, ON);
1089 * Function via_ircc_dma_receive_complete (self)
1091 * Controller Finished with receiving frames,
1092 * and this routine is call by ISR
1095 static int via_ircc_dma_receive_complete(struct via_ircc_cb *self,
1098 struct st_fifo *st_fifo;
1099 struct sk_buff *skb;
1103 iobase = self->io.fir_base;
1104 st_fifo = &self->st_fifo;
1106 if (self->io.speed < 4000000) { //Speed below FIR
1107 len = GetRecvByte(iobase, self);
1108 skb = dev_alloc_skb(len + 1);
1111 // Make sure IP header gets aligned
1112 skb_reserve(skb, 1);
1113 skb_put(skb, len - 2);
1114 if (self->chip_id == 0x3076) {
1115 for (i = 0; i < len - 2; i++)
1116 skb->data[i] = self->rx_buff.data[i * 2];
1118 if (self->chip_id == 0x3096) {
1119 for (i = 0; i < len - 2; i++)
1121 self->rx_buff.data[i];
1124 // Move to next frame
1125 self->rx_buff.data += len;
1126 self->stats.rx_bytes += len;
1127 self->stats.rx_packets++;
1128 skb->dev = self->netdev;
1129 skb->mac.raw = skb->data;
1130 skb->protocol = htons(ETH_P_IRDA);
1136 len = GetRecvByte(iobase, self);
1138 return TRUE; //interrupt only, data maybe move by RxT
1139 if (((len - 4) < 2) || ((len - 4) > 2048)) {
1140 IRDA_DEBUG(1, "%s(): Trouble:len=%x,CurCount=%x,LastCount=%x..\n",
1141 __FUNCTION__, len, RxCurCount(iobase, self),
1146 IRDA_DEBUG(2, "%s(): fifo.len=%x,len=%x,CurCount=%x..\n",
1148 st_fifo->len, len - 4, RxCurCount(iobase, self));
1150 st_fifo->entries[st_fifo->tail].status = status;
1151 st_fifo->entries[st_fifo->tail].len = len;
1152 st_fifo->pending_bytes += len;
1155 if (st_fifo->tail > MAX_RX_WINDOW)
1157 self->RxDataReady = 0;
1159 // It maybe have MAX_RX_WINDOW package receive by
1160 // receive_complete before Timer IRQ
1162 if (st_fifo->len < (MAX_RX_WINDOW+2 )) {
1168 EnableRX(iobase, OFF);
1169 EnRXDMA(iobase, OFF);
1170 RXStart(iobase, OFF);
1172 // Put this entry back in fifo
1173 if (st_fifo->head > MAX_RX_WINDOW)
1175 status = st_fifo->entries[st_fifo->head].status;
1176 len = st_fifo->entries[st_fifo->head].len;
1180 skb = dev_alloc_skb(len + 1 - 4);
1182 * if frame size,data ptr,or skb ptr are wrong ,the get next
1185 if ((skb == NULL) || (skb->data == NULL)
1186 || (self->rx_buff.data == NULL) || (len < 6)) {
1187 self->stats.rx_dropped++;
1190 skb_reserve(skb, 1);
1191 skb_put(skb, len - 4);
1193 memcpy(skb->data, self->rx_buff.data, len - 4);
1194 IRDA_DEBUG(2, "%s(): len=%x.rx_buff=%p\n", __FUNCTION__,
1195 len - 4, self->rx_buff.data);
1197 // Move to next frame
1198 self->rx_buff.data += len;
1199 self->stats.rx_bytes += len;
1200 self->stats.rx_packets++;
1201 skb->dev = self->netdev;
1202 skb->mac.raw = skb->data;
1203 skb->protocol = htons(ETH_P_IRDA);
1213 * if frame is received , but no INT ,then use this routine to upload frame.
1215 static int upload_rxdata(struct via_ircc_cb *self, int iobase)
1217 struct sk_buff *skb;
1219 struct st_fifo *st_fifo;
1220 st_fifo = &self->st_fifo;
1222 len = GetRecvByte(iobase, self);
1224 IRDA_DEBUG(2, "%s(): len=%x\n", __FUNCTION__, len);
1226 if ((len - 4) < 2) {
1227 self->stats.rx_dropped++;
1231 skb = dev_alloc_skb(len + 1);
1233 self->stats.rx_dropped++;
1236 skb_reserve(skb, 1);
1237 skb_put(skb, len - 4 + 1);
1238 memcpy(skb->data, self->rx_buff.data, len - 4 + 1);
1241 if (st_fifo->tail > MAX_RX_WINDOW)
1243 // Move to next frame
1244 self->rx_buff.data += len;
1245 self->stats.rx_bytes += len;
1246 self->stats.rx_packets++;
1247 skb->dev = self->netdev;
1248 skb->mac.raw = skb->data;
1249 skb->protocol = htons(ETH_P_IRDA);
1251 if (st_fifo->len < (MAX_RX_WINDOW + 2)) {
1252 RXStart(iobase, ON);
1254 EnableRX(iobase, OFF);
1255 EnRXDMA(iobase, OFF);
1256 RXStart(iobase, OFF);
1262 * Implement back to back receive , use this routine to upload data.
1265 static int RxTimerHandler(struct via_ircc_cb *self, int iobase)
1267 struct st_fifo *st_fifo;
1268 struct sk_buff *skb;
1272 st_fifo = &self->st_fifo;
1274 if (CkRxRecv(iobase, self)) {
1275 // if still receiving ,then return ,don't upload frame
1276 self->RetryCount = 0;
1277 SetTimer(iobase, 20);
1278 self->RxDataReady++;
1283 if ((self->RetryCount >= 1) ||
1284 ((st_fifo->pending_bytes + 2048) > self->rx_buff.truesize)
1285 || (st_fifo->len >= (MAX_RX_WINDOW))) {
1286 while (st_fifo->len > 0) { //upload frame
1287 // Put this entry back in fifo
1288 if (st_fifo->head > MAX_RX_WINDOW)
1290 status = st_fifo->entries[st_fifo->head].status;
1291 len = st_fifo->entries[st_fifo->head].len;
1295 skb = dev_alloc_skb(len + 1 - 4);
1297 * if frame size, data ptr, or skb ptr are wrong,
1298 * then get next entry.
1300 if ((skb == NULL) || (skb->data == NULL)
1301 || (self->rx_buff.data == NULL) || (len < 6)) {
1302 self->stats.rx_dropped++;
1305 skb_reserve(skb, 1);
1306 skb_put(skb, len - 4);
1307 memcpy(skb->data, self->rx_buff.data, len - 4);
1309 IRDA_DEBUG(2, "%s(): len=%x.head=%x\n", __FUNCTION__,
1310 len - 4, st_fifo->head);
1312 // Move to next frame
1313 self->rx_buff.data += len;
1314 self->stats.rx_bytes += len;
1315 self->stats.rx_packets++;
1316 skb->dev = self->netdev;
1317 skb->mac.raw = skb->data;
1318 skb->protocol = htons(ETH_P_IRDA);
1321 self->RetryCount = 0;
1324 "%s(): End of upload HostStatus=%x,RxStatus=%x\n",
1326 GetHostStatus(iobase), GetRXStatus(iobase));
1329 * if frame is receive complete at this routine ,then upload
1332 if ((GetRXStatus(iobase) & 0x10)
1333 && (RxCurCount(iobase, self) != self->RxLastCount)) {
1334 upload_rxdata(self, iobase);
1335 if (irda_device_txqueue_empty(self->netdev))
1336 via_ircc_dma_receive(self);
1338 } // timer detect complete
1340 SetTimer(iobase, 4);
1348 * Function via_ircc_interrupt (irq, dev_id, regs)
1350 * An interrupt from the chip has arrived. Time to do some work
1353 static irqreturn_t via_ircc_interrupt(int irq, void *dev_id,
1354 struct pt_regs *regs)
1356 struct net_device *dev = (struct net_device *) dev_id;
1357 struct via_ircc_cb *self;
1359 u8 iHostIntType, iRxIntType, iTxIntType;
1362 IRDA_WARNING("%s: irq %d for unknown device.\n", driver_name,
1366 self = (struct via_ircc_cb *) dev->priv;
1367 iobase = self->io.fir_base;
1368 spin_lock(&self->lock);
1369 iHostIntType = GetHostStatus(iobase);
1371 IRDA_DEBUG(4, "%s(): iHostIntType %02x: %s %s %s %02x\n",
1372 __FUNCTION__, iHostIntType,
1373 (iHostIntType & 0x40) ? "Timer" : "",
1374 (iHostIntType & 0x20) ? "Tx" : "",
1375 (iHostIntType & 0x10) ? "Rx" : "",
1376 (iHostIntType & 0x0e) >> 1);
1378 if ((iHostIntType & 0x40) != 0) { //Timer Event
1379 self->EventFlag.TimeOut++;
1380 ClearTimerInt(iobase, 1);
1381 if (self->io.direction == IO_XMIT) {
1382 via_ircc_dma_xmit(self, iobase);
1384 if (self->io.direction == IO_RECV) {
1386 * frame ready hold too long, must reset.
1388 if (self->RxDataReady > 30) {
1390 if (irda_device_txqueue_empty(self->netdev)) {
1391 via_ircc_dma_receive(self);
1393 } else { // call this to upload frame.
1394 RxTimerHandler(self, iobase);
1398 if ((iHostIntType & 0x20) != 0) { //Tx Event
1399 iTxIntType = GetTXStatus(iobase);
1401 IRDA_DEBUG(4, "%s(): iTxIntType %02x: %s %s %s %s\n",
1402 __FUNCTION__, iTxIntType,
1403 (iTxIntType & 0x08) ? "FIFO underr." : "",
1404 (iTxIntType & 0x04) ? "EOM" : "",
1405 (iTxIntType & 0x02) ? "FIFO ready" : "",
1406 (iTxIntType & 0x01) ? "Early EOM" : "");
1408 if (iTxIntType & 0x4) {
1409 self->EventFlag.EOMessage++; // read and will auto clean
1410 if (via_ircc_dma_xmit_complete(self)) {
1411 if (irda_device_txqueue_empty
1413 via_ircc_dma_receive(self);
1416 self->EventFlag.Unknown++;
1420 //----------------------------------------
1421 if ((iHostIntType & 0x10) != 0) { //Rx Event
1422 /* Check if DMA has finished */
1423 iRxIntType = GetRXStatus(iobase);
1425 IRDA_DEBUG(4, "%s(): iRxIntType %02x: %s %s %s %s %s %s %s\n",
1426 __FUNCTION__, iRxIntType,
1427 (iRxIntType & 0x80) ? "PHY err." : "",
1428 (iRxIntType & 0x40) ? "CRC err" : "",
1429 (iRxIntType & 0x20) ? "FIFO overr." : "",
1430 (iRxIntType & 0x10) ? "EOF" : "",
1431 (iRxIntType & 0x08) ? "RxData" : "",
1432 (iRxIntType & 0x02) ? "RxMaxLen" : "",
1433 (iRxIntType & 0x01) ? "SIR bad" : "");
1435 IRDA_DEBUG(3, "%s(): RxIRQ =0\n", __FUNCTION__);
1437 if (iRxIntType & 0x10) {
1438 if (via_ircc_dma_receive_complete(self, iobase)) {
1439 //F01 if(!(IsFIROn(iobase))) via_ircc_dma_receive(self);
1440 via_ircc_dma_receive(self);
1444 IRDA_DEBUG(4, "%s(): RxIRQ ERR:iRxIntType=%x,HostIntType=%x,CurCount=%x,RxLastCount=%x_____\n",
1445 __FUNCTION__, iRxIntType, iHostIntType,
1446 RxCurCount(iobase, self),
1449 if (iRxIntType & 0x20) { //FIFO OverRun ERR
1450 ResetChip(iobase, 0);
1451 ResetChip(iobase, 1);
1452 } else { //PHY,CRC ERR
1454 if (iRxIntType != 0x08)
1455 hwreset(self); //F01
1457 via_ircc_dma_receive(self);
1461 spin_unlock(&self->lock);
1462 return IRQ_RETVAL(iHostIntType);
1465 static void hwreset(struct via_ircc_cb *self)
1468 iobase = self->io.fir_base;
1470 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
1472 ResetChip(iobase, 5);
1473 EnableDMA(iobase, OFF);
1474 EnableTX(iobase, OFF);
1475 EnableRX(iobase, OFF);
1476 EnRXDMA(iobase, OFF);
1477 EnTXDMA(iobase, OFF);
1478 RXStart(iobase, OFF);
1479 TXStart(iobase, OFF);
1482 SIRFilter(iobase, ON);
1486 WriteReg(iobase, I_ST_CT_0, 0x00);
1487 SetBaudRate(iobase, 9600);
1488 SetPulseWidth(iobase, 12);
1489 SetSendPreambleCount(iobase, 0);
1490 WriteReg(iobase, I_ST_CT_0, 0x80);
1492 /* Restore speed. */
1493 via_ircc_change_speed(self, self->io.speed);
1495 self->st_fifo.len = 0;
1499 * Function via_ircc_is_receiving (self)
1501 * Return TRUE is we are currently receiving a frame
1504 static int via_ircc_is_receiving(struct via_ircc_cb *self)
1509 IRDA_ASSERT(self != NULL, return FALSE;);
1511 iobase = self->io.fir_base;
1512 if (CkRxRecv(iobase, self))
1515 IRDA_DEBUG(2, "%s(): status=%x....\n", __FUNCTION__, status);
1522 * Function via_ircc_net_open (dev)
1527 static int via_ircc_net_open(struct net_device *dev)
1529 struct via_ircc_cb *self;
1533 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
1535 IRDA_ASSERT(dev != NULL, return -1;);
1536 self = (struct via_ircc_cb *) dev->priv;
1537 self->stats.rx_packets = 0;
1538 IRDA_ASSERT(self != NULL, return 0;);
1539 iobase = self->io.fir_base;
1540 if (request_irq(self->io.irq, via_ircc_interrupt, 0, dev->name, dev)) {
1541 IRDA_WARNING("%s, unable to allocate irq=%d\n", driver_name,
1546 * Always allocate the DMA channel after the IRQ, and clean up on
1549 if (request_dma(self->io.dma, dev->name)) {
1550 IRDA_WARNING("%s, unable to allocate dma=%d\n", driver_name,
1552 free_irq(self->io.irq, self);
1555 if (self->io.dma2 != self->io.dma) {
1556 if (request_dma(self->io.dma2, dev->name)) {
1557 IRDA_WARNING("%s, unable to allocate dma2=%d\n",
1558 driver_name, self->io.dma2);
1559 free_irq(self->io.irq, self);
1565 /* turn on interrupts */
1566 EnAllInt(iobase, ON);
1567 EnInternalLoop(iobase, OFF);
1568 EnExternalLoop(iobase, OFF);
1571 via_ircc_dma_receive(self);
1573 /* Ready to play! */
1574 netif_start_queue(dev);
1577 * Open new IrLAP layer instance, now that everything should be
1578 * initialized properly
1580 sprintf(hwname, "VIA @ 0x%x", iobase);
1581 self->irlap = irlap_open(dev, &self->qos, hwname);
1583 self->RxLastCount = 0;
1589 * Function via_ircc_net_close (dev)
1594 static int via_ircc_net_close(struct net_device *dev)
1596 struct via_ircc_cb *self;
1599 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
1601 IRDA_ASSERT(dev != NULL, return -1;);
1602 self = (struct via_ircc_cb *) dev->priv;
1603 IRDA_ASSERT(self != NULL, return 0;);
1606 netif_stop_queue(dev);
1607 /* Stop and remove instance of IrLAP */
1609 irlap_close(self->irlap);
1611 iobase = self->io.fir_base;
1612 EnTXDMA(iobase, OFF);
1613 EnRXDMA(iobase, OFF);
1614 DisableDmaChannel(self->io.dma);
1616 /* Disable interrupts */
1617 EnAllInt(iobase, OFF);
1618 free_irq(self->io.irq, dev);
1619 free_dma(self->io.dma);
1625 * Function via_ircc_net_ioctl (dev, rq, cmd)
1627 * Process IOCTL commands for this device
1630 static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq,
1633 struct if_irda_req *irq = (struct if_irda_req *) rq;
1634 struct via_ircc_cb *self;
1635 unsigned long flags;
1638 IRDA_ASSERT(dev != NULL, return -1;);
1640 IRDA_ASSERT(self != NULL, return -1;);
1641 IRDA_DEBUG(1, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name,
1643 /* Disable interrupts & save flags */
1644 spin_lock_irqsave(&self->lock, flags);
1646 case SIOCSBANDWIDTH: /* Set bandwidth */
1647 if (!capable(CAP_NET_ADMIN)) {
1651 via_ircc_change_speed(self, irq->ifr_baudrate);
1653 case SIOCSMEDIABUSY: /* Set media busy */
1654 if (!capable(CAP_NET_ADMIN)) {
1658 irda_device_set_media_busy(self->netdev, TRUE);
1660 case SIOCGRECEIVING: /* Check if we are receiving right now */
1661 irq->ifr_receiving = via_ircc_is_receiving(self);
1667 spin_unlock_irqrestore(&self->lock, flags);
1671 static struct net_device_stats *via_ircc_net_get_stats(struct net_device
1674 struct via_ircc_cb *self = (struct via_ircc_cb *) dev->priv;
1676 return &self->stats;
1679 MODULE_AUTHOR("VIA Technologies,inc");
1680 MODULE_DESCRIPTION("VIA IrDA Device Driver");
1681 MODULE_LICENSE("GPL");
1683 module_init(via_ircc_init);
1684 module_exit(via_ircc_cleanup);