24 #include <linux/module.h>
27 #include <linux/kernel.h>
28 #include <linux/types.h>
30 #include <linux/netdevice.h>
35 #include <linux/rtnetlink.h>
42 #include <asm/byteorder.h>
50 #define CHIP_IO_EXTENT 8
51 #define BROKEN_DONGLE_ID
53 #define ALI_IRCC_DRIVER_NAME "ali-ircc"
60 .suspend = ali_ircc_suspend,
61 .resume = ali_ircc_resume,
69 static int qos_mtt_bits = 0x07;
72 static unsigned int io[] = { ~0, ~0, ~0, ~0 };
73 static unsigned int irq[] = { 0, 0, 0, 0 };
74 static unsigned int dma[] = { 0, 0, 0, 0 };
85 {
"M1543", { 0x3f0, 0x370 }, 0x51, 0x23, 0x20, 0x43, ali_ircc_probe_53, ali_ircc_init_43 },
86 {
"M1535", { 0x3f0, 0x370 }, 0x51, 0x23, 0x20, 0x53, ali_ircc_probe_53, ali_ircc_init_53 },
87 {
"M1563", { 0x3f0, 0x370 }, 0x51, 0x23, 0x20, 0x63, ali_ircc_probe_53, ali_ircc_init_53 },
95 static char *dongle_types[] = {
99 "No dongle connected",
105 static int ali_ircc_close(
struct ali_ircc_cb *
self);
108 static int ali_ircc_is_receiving(
struct ali_ircc_cb *
self);
118 static void ali_ircc_sir_receive(
struct ali_ircc_cb *
self);
119 static void ali_ircc_sir_write_wakeup(
struct ali_ircc_cb *
self);
128 static int ali_ircc_dma_receive(
struct ali_ircc_cb *
self);
129 static int ali_ircc_dma_receive_complete(
struct ali_ircc_cb *
self);
130 static int ali_ircc_dma_xmit_complete(
struct ali_ircc_cb *
self);
131 static void ali_ircc_dma_xmit(
struct ali_ircc_cb *
self);
135 static void ali_ircc_change_dongle_speed(
struct ali_ircc_cb *
priv,
int speed);
138 static void SIR2FIR(
int iobase);
139 static void FIR2SIR(
int iobase);
148 static int __init ali_ircc_init(
void)
157 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__);
169 for (chip= chips; chip->
name; chip++, i++)
171 IRDA_DEBUG(2,
"%s(), Probing for %s ...\n", __func__, chip->
name);
174 for (cfg=0; cfg<2; cfg++)
176 cfg_base = chip->
cfg[
cfg];
192 outb(0x07, cfg_base);
193 outb(0x05, cfg_base+1);
197 reg =
inb(cfg_base+1);
201 IRDA_DEBUG(2,
"%s(), Chip found at 0x%03x\n", __func__, cfg_base);
203 outb(0x1F, cfg_base);
204 revision =
inb(cfg_base+1);
205 IRDA_DEBUG(2,
"%s(), Found %s chip, revision=%d\n", __func__,
206 chip->
name, revision);
215 chip->
init(chip, &info);
219 chip->
probe(chip, &info);
222 if (ali_ircc_open(i, &info) == 0)
228 IRDA_DEBUG(2,
"%s(), No %s chip at 0x%03x\n", __func__, chip->
name, cfg_base);
231 outb(0xbb, cfg_base);
235 IRDA_DEBUG(2,
"%s(), ----------------- End -----------------\n", __func__);
249 static void __exit ali_ircc_cleanup(
void)
253 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__);
257 ali_ircc_close(dev_self[i]);
262 IRDA_DEBUG(2,
"%s(), ----------------- End -----------------\n", __func__);
266 .ndo_open = ali_ircc_net_open,
267 .ndo_stop = ali_ircc_net_close,
268 .ndo_start_xmit = ali_ircc_sir_hard_xmit,
269 .ndo_do_ioctl = ali_ircc_net_ioctl,
273 .ndo_open = ali_ircc_net_open,
274 .ndo_stop = ali_ircc_net_close,
275 .ndo_start_xmit = ali_ircc_fir_hard_xmit,
276 .ndo_do_ioctl = ali_ircc_net_ioctl,
285 static int ali_ircc_open(
int i,
chipio_t *info)
292 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__);
295 IRDA_ERROR(
"%s(), maximum number of supported chips reached!\n",
301 if ((ali_ircc_setup(info)) == -1)
306 IRDA_ERROR(
"%s(), can't allocate memory for control block!\n",
311 self = netdev_priv(dev);
323 self->io.irq = info->
irq;
325 self->io.dma = info->
dma;
326 self->io.fifo_size = 16;
331 IRDA_WARNING(
"%s(), can't get iobase of 0x%03x\n", __func__,
344 self->qos.min_turn_time.bits = qos_mtt_bits;
349 self->rx_buff.truesize = 14384;
350 self->tx_buff.truesize = 14384;
356 if (self->rx_buff.head ==
NULL) {
360 memset(self->rx_buff.head, 0, self->rx_buff.truesize);
365 if (self->tx_buff.head ==
NULL) {
369 memset(self->tx_buff.head, 0, self->tx_buff.truesize);
371 self->rx_buff.in_frame =
FALSE;
373 self->tx_buff.data =
self->tx_buff.head;
374 self->rx_buff.data =
self->rx_buff.head;
377 self->tx_fifo.len =
self->tx_fifo.ptr =
self->tx_fifo.free = 0;
378 self->tx_fifo.tail =
self->tx_buff.head;
385 IRDA_ERROR(
"%s(), register_netdev() failed!\n", __func__);
391 dongle_id = ali_ircc_read_dongle_id(i, info);
395 self->io.dongle_id = dongle_id;
397 IRDA_DEBUG(2,
"%s(), ----------------- End -----------------\n", __func__);
403 self->tx_buff.head, self->tx_buff_dma);
406 self->rx_buff.head, self->rx_buff_dma);
426 IRDA_DEBUG(4,
"%s(), ---------------- Start ----------------\n", __func__);
430 iobase =
self->io.fir_base;
436 IRDA_DEBUG(4,
"%s(), Releasing Region %03x\n", __func__, self->io.fir_base);
439 if (self->tx_buff.head)
441 self->tx_buff.head, self->tx_buff_dma);
443 if (self->rx_buff.head)
445 self->rx_buff.head, self->rx_buff_dma);
447 dev_self[
self->index] =
NULL;
450 IRDA_DEBUG(2,
"%s(), ----------------- End -----------------\n", __func__);
493 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__);
500 outb(0x07, cfg_base);
501 outb(0x05, cfg_base+1);
504 outb(0x60, cfg_base);
505 hi =
inb(cfg_base+1);
506 outb(0x61, cfg_base);
507 low =
inb(cfg_base+1);
515 outb(0x70, cfg_base);
516 reg =
inb(cfg_base+1);
517 info->
irq = reg & 0x0f;
518 IRDA_DEBUG(2,
"%s(), probing irq=%d\n", __func__, info->
irq);
521 outb(0x74, cfg_base);
522 reg =
inb(cfg_base+1);
523 info->
dma = reg & 0x07;
525 if(info->
dma == 0x04)
526 IRDA_WARNING(
"%s(), No DMA channel assigned !\n", __func__);
528 IRDA_DEBUG(2,
"%s(), probing dma=%d\n", __func__, info->
dma);
531 outb(0x30, cfg_base);
532 reg =
inb(cfg_base+1);
533 info->
enabled = (reg & 0x80) && (reg & 0x01);
537 outb(0x22, cfg_base);
538 reg =
inb(cfg_base+1);
543 outb(0xbb, cfg_base);
545 IRDA_DEBUG(2,
"%s(), ----------------- End -----------------\n", __func__);
557 static int ali_ircc_setup(
chipio_t *info)
563 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__);
577 switch_bank(iobase,
BANK3);
589 switch_bank(iobase,
BANK1);
596 switch_bank(iobase,
BANK2);
602 switch_bank(iobase,
BANK0);
624 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__);
636 static int ali_ircc_read_dongle_id (
int i,
chipio_t *info)
641 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__);
644 outb(chips[i].entr1, cfg_base);
645 outb(chips[i].entr2, cfg_base);
648 outb(0x07, cfg_base);
649 outb(0x05, cfg_base+1);
652 outb(0xf0, cfg_base);
653 reg =
inb(cfg_base+1);
654 dongle_id = ((reg>>6)&0x02) | ((reg>>5)&0x01);
655 IRDA_DEBUG(2,
"%s(), probing dongle_id=%d, dongle_types=%s\n", __func__,
656 dongle_id, dongle_types[dongle_id]);
659 outb(0xbb, cfg_base);
661 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__);
678 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__);
680 self = netdev_priv(dev);
682 spin_lock(&self->lock);
685 if (self->io.speed > 115200)
686 ret = ali_ircc_fir_interrupt(
self);
688 ret = ali_ircc_sir_interrupt(
self);
690 spin_unlock(&self->lock);
692 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__);
703 __u8 eir, OldMessageCount;
706 IRDA_DEBUG(1,
"%s(), ---------------- Start ----------------\n", __func__);
708 iobase =
self->io.fir_base;
710 switch_bank(iobase,
BANK0);
714 OldMessageCount = (
self->LineStatus + 1) & 0x07;
717 eir =
self->InterruptID &
self->ier;
719 IRDA_DEBUG(1,
"%s(), self->InterruptID = %x\n", __func__,self->InterruptID);
720 IRDA_DEBUG(1,
"%s(), self->LineStatus = %x\n", __func__,self->LineStatus);
721 IRDA_DEBUG(1,
"%s(), self->ier = %x\n", __func__,self->ier);
722 IRDA_DEBUG(1,
"%s(), eir = %x\n", __func__,eir);
725 SetCOMInterrupts(
self,
FALSE);
731 if (self->io.direction ==
IO_XMIT)
733 IRDA_DEBUG(1,
"%s(), ******* IIR_EOM (Tx) *******\n", __func__);
735 if(ali_ircc_dma_xmit_complete(
self))
737 if (irda_device_txqueue_empty(self->netdev))
740 ali_ircc_dma_receive(
self);
752 IRDA_DEBUG(1,
"%s(), ******* IIR_EOM (Rx) *******\n", __func__);
754 if(OldMessageCount > ((self->LineStatus+1) & 0x07))
756 self->rcvFramesOverflow =
TRUE;
757 IRDA_DEBUG(1,
"%s(), ******* self->rcvFramesOverflow = TRUE ********\n", __func__);
760 if (ali_ircc_dma_receive_complete(
self))
762 IRDA_DEBUG(1,
"%s(), ******* receive complete ********\n", __func__);
768 IRDA_DEBUG(1,
"%s(), ******* Not receive complete ********\n", __func__);
778 if(OldMessageCount > ((self->LineStatus+1) & 0x07))
780 self->rcvFramesOverflow =
TRUE;
781 IRDA_DEBUG(1,
"%s(), ******* self->rcvFramesOverflow = TRUE *******\n", __func__);
784 switch_bank(iobase,
BANK1);
789 if (self->io.direction ==
IO_XMIT)
791 ali_ircc_dma_xmit(
self);
799 if(ali_ircc_dma_receive_complete(
self))
811 SetCOMInterrupts(
self,
TRUE);
813 IRDA_DEBUG(1,
"%s(), ----------------- End ---------------\n", __func__);
828 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__);
830 iobase =
self->io.sir_base;
837 IRDA_DEBUG(4,
"%s(), iir=%02x, lsr=%02x, iobase=%#x\n", __func__,
847 ali_ircc_sir_receive(
self);
853 ali_ircc_sir_write_wakeup(
self);
857 IRDA_DEBUG(0,
"%s(), unhandled IIR=%#x\n", __func__, iir);
864 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__);
876 static void ali_ircc_sir_receive(
struct ali_ircc_cb *
self)
881 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__);
884 iobase =
self->io.sir_base;
895 if (boguscount++ > 32) {
901 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__ );
911 static void ali_ircc_sir_write_wakeup(
struct ali_ircc_cb *
self)
918 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__ );
920 iobase =
self->io.sir_base;
923 if (self->tx_buff.len > 0)
926 actual = ali_ircc_sir_write(iobase, self->io.fifo_size,
927 self->tx_buff.data, self->tx_buff.len);
928 self->tx_buff.data += actual;
929 self->tx_buff.len -= actual;
937 IRDA_DEBUG(1,
"%s(), UART_LSR_THRE\n", __func__ );
939 IRDA_DEBUG(1,
"%s(), Changing speed! self->new_speed = %d\n", __func__ , self->new_speed);
940 ali_ircc_change_speed(
self, self->new_speed);
944 if (self->io.speed > 115200)
946 IRDA_DEBUG(2,
"%s(), ali_ircc_change_speed from UART_LSR_TEMT\n", __func__ );
955 netif_wake_queue(self->netdev);
958 self->netdev->stats.tx_packets++;
964 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__ );
972 IRDA_DEBUG(1,
"%s(), ---------------- Start ----------------\n", __func__ );
974 IRDA_DEBUG(2,
"%s(), setting speed = %d\n", __func__ , baud);
979 iobase =
self->io.fir_base;
981 SetCOMInterrupts(
self,
FALSE);
988 ali_ircc_fir_change_speed(
self, baud);
997 ali_ircc_dma_receive(
self);
1002 ali_ircc_sir_change_speed(
self, baud);
1009 SetCOMInterrupts(
self,
TRUE);
1011 netif_wake_queue(self->netdev);
1013 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__ );
1023 IRDA_DEBUG(1,
"%s(), ---------------- Start ----------------\n", __func__ );
1028 iobase =
self->io.fir_base;
1030 IRDA_DEBUG(1,
"%s(), self->io.speed = %d, change to speed = %d\n", __func__ ,self->io.speed,baud);
1033 if(self->io.speed <=115200)
1039 self->io.speed =
baud;
1042 ali_ircc_change_dongle_speed(
self, baud);
1044 IRDA_DEBUG(1,
"%s(), ----------------- End ------------------\n", __func__ );
1053 static void ali_ircc_sir_change_speed(
struct ali_ircc_cb *priv,
__u32 speed)
1056 unsigned long flags;
1062 IRDA_DEBUG(1,
"%s(), ---------------- Start ----------------\n", __func__ );
1064 IRDA_DEBUG(1,
"%s(), Setting speed to: %d\n", __func__ , speed);
1068 iobase =
self->io.sir_base;
1071 if(self->io.speed >115200)
1074 ali_ircc_change_dongle_speed(
self, speed);
1085 self->io.speed = speed;
1089 divisor = 115200/speed;
1098 if (self->io.speed < 38400)
1116 spin_unlock_irqrestore(&self->lock, flags);
1118 IRDA_DEBUG(1,
"%s(), ----------------- End ------------------\n", __func__ );
1121 static void ali_ircc_change_dongle_speed(
struct ali_ircc_cb *priv,
int speed)
1128 IRDA_DEBUG(1,
"%s(), ---------------- Start ----------------\n", __func__ );
1130 iobase =
self->io.fir_base;
1131 dongle_id =
self->io.dongle_id;
1135 IRDA_DEBUG(1,
"%s(), Set Speed for %s , Speed = %d\n", __func__ , dongle_types[dongle_id], speed);
1137 switch_bank(iobase,
BANK2);
1143 if(speed == 4000000)
1154 switch_bank(iobase,
BANK2);
1210 switch_bank(iobase,
BANK2);
1237 else if (dongle_id == 1)
1257 switch_bank(iobase,
BANK2);
1267 switch_bank(iobase,
BANK2);
1292 switch_bank(iobase,
BANK2);
1297 switch_bank(iobase,
BANK0);
1299 IRDA_DEBUG(1,
"%s(), ----------------- End ------------------\n", __func__ );
1308 static int ali_ircc_sir_write(
int iobase,
int fifo_size,
__u8 *
buf,
int len)
1312 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__ );
1316 IRDA_DEBUG(0,
"%s(), failed, fifo not empty!\n", __func__ );
1321 while ((fifo_size-- > 0) && (actual < len)) {
1328 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__ );
1338 static int ali_ircc_net_open(
struct net_device *dev)
1344 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__ );
1348 self = netdev_priv(dev);
1352 iobase =
self->io.fir_base;
1379 netif_start_queue(dev);
1382 sprintf(hwname,
"ALI-FIR @ 0x%03x", self->io.fir_base);
1388 self->irlap =
irlap_open(dev, &self->qos, hwname);
1390 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__ );
1401 static int ali_ircc_net_close(
struct net_device *dev)
1407 IRDA_DEBUG(4,
"%s(), ---------------- Start ----------------\n", __func__ );
1411 self = netdev_priv(dev);
1415 netif_stop_queue(dev);
1425 SetCOMInterrupts(
self,
FALSE);
1430 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__ );
1445 unsigned long flags;
1450 IRDA_DEBUG(1,
"%s(), ---------------- Start -----------------\n", __func__ );
1452 self = netdev_priv(dev);
1453 iobase =
self->io.fir_base;
1455 netif_stop_queue(dev);
1465 speed = irda_get_next_speed(skb);
1466 if ((speed != self->io.speed) && (speed != -1)) {
1469 ali_ircc_change_speed(
self, speed);
1471 spin_unlock_irqrestore(&self->lock, flags);
1475 self->new_speed = speed;
1479 self->tx_fifo.queue[
self->tx_fifo.free].start =
self->tx_fifo.tail;
1480 self->tx_fifo.queue[
self->tx_fifo.free].len = skb->
len;
1481 self->tx_fifo.tail += skb->
len;
1485 skb_copy_from_linear_data(skb, self->tx_fifo.queue[self->tx_fifo.free].start,
1487 self->tx_fifo.len++;
1488 self->tx_fifo.free++;
1491 if (self->tx_fifo.len == 1)
1494 mtt = irda_get_mtt(skb);
1501 diff =
self->now.tv_usec -
self->stamp.tv_usec;
1504 IRDA_DEBUG(1,
"%s(), ******* diff = %d *******\n", __func__ , diff);
1524 mtt = (mtt+250) / 500;
1526 IRDA_DEBUG(1,
"%s(), ************** mtt = %d ***********\n", __func__ , mtt);
1531 switch_bank(iobase,
BANK1);
1536 switch_bank(iobase,
BANK1);
1541 switch_bank(iobase,
BANK1);
1552 SetCOMInterrupts(
self,
TRUE);
1564 SetCOMInterrupts(
self,
TRUE);
1567 ali_ircc_dma_xmit(
self);
1574 netif_wake_queue(self->netdev);
1577 switch_bank(iobase,
BANK0);
1580 spin_unlock_irqrestore(&self->lock, flags);
1583 IRDA_DEBUG(1,
"%s(), ----------------- End ------------------\n", __func__ );
1588 static void ali_ircc_dma_xmit(
struct ali_ircc_cb *
self)
1591 unsigned char FIFO_OPTI,
Hi, Lo;
1594 IRDA_DEBUG(1,
"%s(), ---------------- Start -----------------\n", __func__ );
1596 iobase =
self->io.fir_base;
1601 FIFO_OPTI =
self->tx_fifo.queue[
self->tx_fifo.ptr].len-1;
1606 switch_bank(iobase,
BANK1);
1612 ((
u8 *)self->tx_fifo.queue[self->tx_fifo.ptr].start -
1613 self->tx_buff.head) + self->tx_buff_dma,
1614 self->tx_fifo.queue[self->tx_fifo.ptr].len,
1618 switch_bank(iobase,
BANK0);
1622 if (self->fifo_opti_buf!=FIFO_OPTI)
1624 switch_bank(iobase,
BANK1);
1626 self->fifo_opti_buf=FIFO_OPTI;
1630 switch_bank(iobase,
BANK1);
1634 Hi = (
self->tx_fifo.queue[
self->tx_fifo.ptr].len >> 8) & 0x0f;
1635 Lo =
self->tx_fifo.queue[
self->tx_fifo.ptr].len & 0xff;
1636 switch_bank(iobase,
BANK2);
1641 switch_bank(iobase,
BANK0);
1650 switch_bank(iobase,
BANK1);
1653 switch_bank(iobase,
BANK0);
1655 IRDA_DEBUG(1,
"%s(), ----------------- End ------------------\n", __func__ );
1658 static int ali_ircc_dma_xmit_complete(
struct ali_ircc_cb *
self)
1663 IRDA_DEBUG(1,
"%s(), ---------------- Start -----------------\n", __func__ );
1665 iobase =
self->io.fir_base;
1668 switch_bank(iobase,
BANK1);
1672 switch_bank(iobase,
BANK0);
1676 IRDA_ERROR(
"%s(), ********* LSR_FRAME_ABORT *********\n", __func__);
1677 self->netdev->stats.tx_errors++;
1678 self->netdev->stats.tx_fifo_errors++;
1682 self->netdev->stats.tx_packets++;
1686 if (self->new_speed)
1688 ali_ircc_change_speed(
self, self->new_speed);
1689 self->new_speed = 0;
1693 self->tx_fifo.ptr++;
1694 self->tx_fifo.len--;
1697 if (self->tx_fifo.len)
1699 ali_ircc_dma_xmit(
self);
1706 self->tx_fifo.len =
self->tx_fifo.ptr =
self->tx_fifo.free = 0;
1707 self->tx_fifo.tail =
self->tx_buff.head;
1714 netif_wake_queue(self->netdev);
1717 switch_bank(iobase,
BANK0);
1719 IRDA_DEBUG(1,
"%s(), ----------------- End ------------------\n", __func__ );
1730 static int ali_ircc_dma_receive(
struct ali_ircc_cb *
self)
1734 IRDA_DEBUG(1,
"%s(), ---------------- Start -----------------\n", __func__ );
1736 iobase =
self->io.fir_base;
1739 self->tx_fifo.len =
self->tx_fifo.ptr =
self->tx_fifo.free = 0;
1740 self->tx_fifo.tail =
self->tx_buff.head;
1743 switch_bank(iobase,
BANK1);
1747 switch_bank(iobase,
BANK0);
1750 self->rcvFramesOverflow =
FALSE;
1756 self->rx_buff.data =
self->rx_buff.head;
1762 self->st_fifo.len =
self->st_fifo.pending_bytes = 0;
1763 self->st_fifo.tail =
self->st_fifo.head = 0;
1765 irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
1775 switch_bank(iobase,
BANK1);
1783 switch_bank(iobase,
BANK0);
1784 IRDA_DEBUG(1,
"%s(), ----------------- End ------------------\n", __func__ );
1788 static int ali_ircc_dma_receive_complete(
struct ali_ircc_cb *
self)
1795 IRDA_DEBUG(1,
"%s(), ---------------- Start -----------------\n", __func__ );
1797 st_fifo = &
self->st_fifo;
1798 iobase =
self->io.fir_base;
1800 switch_bank(iobase,
BANK0);
1803 if (MessageCount > 0)
1804 IRDA_DEBUG(0,
"%s(), Message count = %d,\n", __func__ , MessageCount);
1806 for (i=0; i<=MessageCount; i++)
1809 switch_bank(iobase,
BANK0);
1812 switch_bank(iobase,
BANK2);
1817 IRDA_DEBUG(1,
"%s(), RX Length = 0x%.2x,\n", __func__ , len);
1818 IRDA_DEBUG(1,
"%s(), RX Status = 0x%.2x,\n", __func__ , status);
1821 IRDA_DEBUG(0,
"%s(), window is full!\n", __func__ );
1832 for (i=0; i<=MessageCount; i++)
1842 if ((status & 0xd8) || self->rcvFramesOverflow || (len==0))
1844 IRDA_DEBUG(0,
"%s(), ************* RX Errors ************\n", __func__ );
1847 self->netdev->stats.rx_errors++;
1849 self->rx_buff.data +=
len;
1853 self->netdev->stats.rx_frame_errors++;
1854 IRDA_DEBUG(0,
"%s(), ************* FIFO Errors ************\n", __func__ );
1858 self->netdev->stats.rx_frame_errors++;
1859 IRDA_DEBUG(0,
"%s(), ************* FRAME Errors ************\n", __func__ );
1864 self->netdev->stats.rx_crc_errors++;
1865 IRDA_DEBUG(0,
"%s(), ************* CRC Errors ************\n", __func__ );
1868 if(self->rcvFramesOverflow)
1870 self->netdev->stats.rx_frame_errors++;
1871 IRDA_DEBUG(0,
"%s(), ************* Overran DMA buffer ************\n", __func__ );
1875 self->netdev->stats.rx_frame_errors++;
1876 IRDA_DEBUG(0,
"%s(), ********** Receive Frame Size = 0 *********\n", __func__ );
1884 switch_bank(iobase,
BANK0);
1888 IRDA_DEBUG(0,
"%s(), ************* BSR_FIFO_NOT_EMPTY ************\n", __func__ );
1903 switch_bank(iobase,
BANK1);
1920 skb = dev_alloc_skb(len+1);
1924 "dropping frame.\n",
1926 self->netdev->stats.rx_dropped++;
1932 skb_reserve(skb, 1);
1936 skb_copy_to_linear_data(skb, self->rx_buff.
data, len);
1939 self->rx_buff.data +=
len;
1940 self->netdev->stats.rx_bytes +=
len;
1941 self->netdev->stats.rx_packets++;
1943 skb->
dev =
self->netdev;
1944 skb_reset_mac_header(skb);
1950 switch_bank(iobase,
BANK0);
1952 IRDA_DEBUG(1,
"%s(), ----------------- End ------------------\n", __func__ );
1968 unsigned long flags;
1972 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__ );
1976 self = netdev_priv(dev);
1979 iobase =
self->io.sir_base;
1981 netif_stop_queue(dev);
1991 speed = irda_get_next_speed(skb);
1992 if ((speed != self->io.speed) && (speed != -1)) {
1995 ali_ircc_change_speed(
self, speed);
1997 spin_unlock_irqrestore(&self->lock, flags);
2001 self->new_speed = speed;
2005 self->tx_buff.data =
self->tx_buff.head;
2009 self->tx_buff.truesize);
2011 self->netdev->stats.tx_bytes +=
self->tx_buff.len;
2017 spin_unlock_irqrestore(&self->lock, flags);
2021 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__ );
2037 unsigned long flags;
2040 IRDA_DEBUG(2,
"%s(), ---------------- Start ----------------\n", __func__ );
2044 self = netdev_priv(dev);
2048 IRDA_DEBUG(2,
"%s(), %s, (cmd=0x%X)\n", __func__ , dev->
name, cmd);
2052 IRDA_DEBUG(1,
"%s(), SIOCSBANDWIDTH\n", __func__ );
2062 ali_ircc_change_speed(
self, irq->ifr_baudrate);
2063 spin_unlock_irqrestore(&self->lock, flags);
2066 IRDA_DEBUG(1,
"%s(), SIOCSMEDIABUSY\n", __func__ );
2072 IRDA_DEBUG(2,
"%s(), SIOCGRECEIVING\n", __func__ );
2074 irq->ifr_receiving = ali_ircc_is_receiving(
self);
2080 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__ );
2091 static int ali_ircc_is_receiving(
struct ali_ircc_cb *
self)
2093 unsigned long flags;
2097 IRDA_DEBUG(2,
"%s(), ---------------- Start -----------------\n", __func__ );
2103 if (self->io.speed > 115200)
2105 iobase =
self->io.fir_base;
2107 switch_bank(iobase,
BANK1);
2111 IRDA_DEBUG(1,
"%s(), We are receiving something\n", __func__ );
2114 switch_bank(iobase,
BANK0);
2121 spin_unlock_irqrestore(&self->lock, flags);
2123 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__ );
2130 struct ali_ircc_cb *
self = platform_get_drvdata(dev);
2134 if (self->io.suspended)
2137 ali_ircc_net_close(self->netdev);
2139 self->io.suspended = 1;
2146 struct ali_ircc_cb *
self = platform_get_drvdata(dev);
2148 if (!self->io.suspended)
2151 ali_ircc_net_open(self->netdev);
2155 self->io.suspended = 0;
2165 unsigned char newMask;
2167 int iobase =
self->io.fir_base;
2169 IRDA_DEBUG(2,
"%s(), -------- Start -------- ( Enable = %d )\n", __func__ , enable);
2173 if (self->io.direction ==
IO_XMIT)
2175 if (self->io.speed > 115200)
2177 newMask =
self->ier;
2185 if (self->io.speed > 115200)
2187 newMask =
self->ier;
2202 if (self->io.speed > 115200)
2204 switch_bank(iobase,
BANK0);
2210 IRDA_DEBUG(2,
"%s(), ----------------- End ------------------\n", __func__ );
2213 static void SIR2FIR(
int iobase)
2217 IRDA_DEBUG(1,
"%s(), ---------------- Start ----------------\n", __func__ );
2233 IRDA_DEBUG(1,
"%s(), ----------------- End ------------------\n", __func__ );
2236 static void FIR2SIR(
int iobase)
2240 IRDA_DEBUG(1,
"%s(), ---------------- Start ----------------\n", __func__ );
2256 IRDA_DEBUG(1,
"%s(), ----------------- End ------------------\n", __func__ );