patch-2.2.6 linux/drivers/net/irda/w83977af_ir.c
Next file: linux/drivers/net/rclanmtl.c
Previous file: linux/drivers/net/irda/uircc.c
Back to the patch index
Back to the overall index
- Lines: 608
- Date:
Thu Apr 15 05:42:41 1999
- Orig file:
v2.2.5/linux/drivers/net/irda/w83977af_ir.c
- Orig date:
Wed Mar 10 15:29:46 1999
diff -u --recursive --new-file v2.2.5/linux/drivers/net/irda/w83977af_ir.c linux/drivers/net/irda/w83977af_ir.c
@@ -6,7 +6,7 @@
* Status: Experimental.
* Author: Paul VanderSpek
* Created at: Wed Nov 4 11:46:16 1998
- * Modified at: Tue Feb 9 13:30:35 1999
+ * Modified at: Wed Apr 7 17:35:59 1999
* Modified by: Dag Brattli <dagb@cs.uit.no>
*
* Copyright (c) 1998 Corel Computer Corp.
@@ -22,7 +22,7 @@
* provided "AS-IS" and at no charge.
*
* If you find bugs in this file, its very likely that the same bug
- * will also be in w83977af_ir.c since the implementations is quite
+ * will also be in pc87108.c since the implementations is quite
* similar.
*
* Notice that all functions that needs to access the chip in _any_
@@ -67,8 +67,8 @@
#define CHIP_IO_EXTENT 8
-static unsigned int io[] = { 0x400, ~0, ~0, ~0 };
-static unsigned int irq[] = { 22, 0, 0, 0 };
+static unsigned int io[] = { 0x180, ~0, ~0, ~0 };
+static unsigned int irq[] = { 6, 0, 0, 0 };
static unsigned int dma[] = { 0, 0, 0, 0 };
static struct irda_device *dev_self[] = { NULL, NULL, NULL, NULL};
@@ -116,7 +116,7 @@
for ( i=0; (io[i] < 2000) && (i < 4); i++) {
int ioaddr = io[i];
- if (check_region(ioaddr, CHIP_IO_EXTENT))
+ if (check_region(ioaddr, CHIP_IO_EXTENT) < 0)
continue;
if (w83977af_open( i, io[i], irq[i], dma[i]) == 0)
return 0;
@@ -216,7 +216,6 @@
idev->tx_buff.truesize = 4000;
/* Initialize callbacks */
- idev->hard_xmit = w83977af_hard_xmit;
idev->change_speed = w83977af_change_speed;
idev->wait_until_sent = w83977af_wait_until_sent;
idev->is_receiving = w83977af_is_receiving;
@@ -290,9 +289,10 @@
/* Configure PnP port, IRQ, and DMA channel */
w977_write_reg(0x60, (iobase >> 8) & 0xff);
w977_write_reg(0x61, (iobase) & 0xff);
- w977_write_reg(0x70, 0x06);
+ /* w977_write_reg(0x70, 0x06); */
+ w977_write_reg(0x70, irq);
#ifdef NETWINDER
- w977_write_reg(0x74, dma+1); /* Netwinder uses 1 higher than Linux */
+ w977_write_reg(0x74, dma+1); /* Netwinder uses one higher than Linux */
#else
w977_write_reg(0x74, dma);
#endif
@@ -433,7 +433,7 @@
/* set FIFO threshold to TX17, RX16 */
switch_bank(iobase, SET0);
- outb( UFR_RXTL|UFR_TXTL|UFR_TXF_RST|UFR_RXF_RST|UFR_EN_FIFO, iobase+UFR);
+ outb(UFR_RXTL|UFR_TXTL|UFR_TXF_RST|UFR_RXF_RST|UFR_EN_FIFO, iobase+UFR);
idev->netdev.tbusy = 0;
@@ -464,65 +464,65 @@
idev = (struct irda_device *) dev->priv;
- ASSERT( idev != NULL, return 0;);
- ASSERT( idev->magic == IRDA_DEVICE_MAGIC, return 0;);
+ ASSERT(idev != NULL, return 0;);
+ ASSERT(idev->magic == IRDA_DEVICE_MAGIC, return 0;);
iobase = idev->io.iobase;
DEBUG(4, __FUNCTION__ "(%ld), skb->len=%d\n", jiffies, (int) skb->len);
/* Lock transmit buffer */
- if ( irda_lock( (void *) &dev->tbusy) == FALSE)
+ if (irda_lock((void *) &dev->tbusy) == FALSE)
return -EBUSY;
-
+
/* Save current set */
- set = inb( iobase+SSR);
+ set = inb(iobase+SSR);
/* Decide if we should use PIO or DMA transfer */
- if ( idev->io.baudrate > 115200) {
- memcpy( idev->tx_buff.data, skb->data, skb->len);
+ if (idev->io.baudrate > 115200) {
+ memcpy(idev->tx_buff.data, skb->data, skb->len);
idev->tx_buff.len = skb->len;
idev->tx_buff.head = idev->tx_buff.data;
idev->tx_buff.offset = 0;
- mtt = irda_get_mtt( skb);
- if ( mtt > 50) {
+ mtt = irda_get_mtt(skb);
+ if (mtt > 50) {
/* Adjust for timer resolution */
- mtt /= 1000+1;
+ mtt = mtt / 1000 + 1;
/* Setup timer */
- switch_bank( iobase, SET4);
- outb( mtt & 0xff, iobase+TMRL);
- outb(( mtt >> 8) & 0x0f, iobase+TMRH);
+ switch_bank(iobase, SET4);
+ outb(mtt & 0xff, iobase+TMRL);
+ outb((mtt >> 8) & 0x0f, iobase+TMRH);
/* Start timer */
- outb( IR_MSL_EN_TMR, iobase+IR_MSL);
+ outb(IR_MSL_EN_TMR, iobase+IR_MSL);
idev->io.direction = IO_XMIT;
/* Enable timer interrupt */
- switch_bank( iobase, SET0);
- outb( ICR_ETMRI, iobase+ICR);
+ switch_bank(iobase, SET0);
+ outb(ICR_ETMRI, iobase+ICR);
} else {
- if ( mtt)
- udelay( mtt);
+ if (mtt)
+ udelay(mtt);
/* Enable DMA interrupt */
- switch_bank( iobase, SET0);
- outb( ICR_EDMAI, iobase+ICR);
- w83977af_dma_write( idev, iobase);
+ switch_bank(iobase, SET0);
+ outb(ICR_EDMAI, iobase+ICR);
+ w83977af_dma_write(idev, iobase);
}
} else {
- idev->tx_buff.len = async_wrap_skb( skb, idev->tx_buff.data,
- idev->tx_buff.truesize);
+ idev->tx_buff.len = async_wrap_skb(skb, idev->tx_buff.data,
+ idev->tx_buff.truesize);
idev->tx_buff.offset = 0;
idev->tx_buff.head = idev->tx_buff.data;
/* Add interrupt on tx low level (will fire immediately) */
switch_bank( iobase, SET0);
- outb( ICR_ETXTHI, iobase+ICR);
+ outb(ICR_ETXTHI, iobase+ICR);
}
- dev_kfree_skb( skb);
+ dev_kfree_skb(skb);
/* Restore set register */
outb( set, iobase+SSR);
@@ -550,23 +550,23 @@
switch_bank(iobase, SET0);
outb( inb( iobase+HCR) & ~HCR_EN_DMA, iobase+HCR);
- setup_dma( idev->io.dma, idev->tx_buff.data, idev->tx_buff.len,
- DMA_MODE_WRITE);
+ setup_dma(idev->io.dma, idev->tx_buff.data, idev->tx_buff.len,
+ DMA_MODE_WRITE);
/* idev->media_busy = TRUE; */
idev->io.direction = IO_XMIT;
/* Choose transmit DMA channel */
switch_bank(iobase, SET2);
- outb( inb( iobase+ADCR1) | ADCR1_D_CHSW|ADCR1_DMA_F|ADCR1_ADV_SL,
- iobase+ADCR1);
+ outb(inb(iobase+ADCR1) | ADCR1_D_CHSW|ADCR1_DMA_F|ADCR1_ADV_SL,
+ iobase+ADCR1);
/* Enable DMA */
- switch_bank( iobase, SET0);
- outb( inb( iobase+HCR) | HCR_EN_DMA, iobase+HCR);
+ switch_bank(iobase, SET0);
+ outb(inb(iobase+HCR) | HCR_EN_DMA, iobase+HCR);
/* Restore set register */
- outb( set, iobase+SSR);
+ outb(set, iobase+SSR);
}
/*
@@ -575,7 +575,7 @@
*
*
*/
-static int w83977af_pio_write( int iobase, __u8 *buf, int len, int fifo_size)
+static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
{
int actual = 0;
__u8 set;
@@ -586,7 +586,7 @@
set = inb( iobase+SSR);
switch_bank( iobase, SET0);
- if (!( inb_p( iobase+USR) & USR_TSRE)) {
+ if (!(inb_p(iobase+USR) & USR_TSRE)) {
DEBUG( 4, __FUNCTION__ "(), warning, FIFO not empty yet!\n");
fifo_size -= 17;
@@ -599,11 +599,11 @@
outb( buf[actual++], iobase+TBR);
}
- DEBUG( 4, __FUNCTION__ "(), fifo_size %d ; %d sent of %d\n",
- fifo_size, actual, len);
+ DEBUG(4, __FUNCTION__ "(), fifo_size %d ; %d sent of %d\n",
+ fifo_size, actual, len);
/* Restore bank */
- outb( set, iobase+SSR);
+ outb(set, iobase+SSR);
return actual;
}
@@ -615,34 +615,34 @@
*
*
*/
-void w83977af_dma_xmit_complete( struct irda_device *idev)
+void w83977af_dma_xmit_complete(struct irda_device *idev)
{
int iobase;
__u8 set;
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(4, __FUNCTION__ "()\n");
- ASSERT( idev != NULL, return;);
- ASSERT( idev->magic == IRDA_DEVICE_MAGIC, return;);
+ ASSERT(idev != NULL, return;);
+ ASSERT(idev->magic == IRDA_DEVICE_MAGIC, return;);
iobase = idev->io.iobase;
/* Save current set */
- set = inb( iobase+SSR);
+ set = inb(iobase+SSR);
/* Disable DMA */
switch_bank(iobase, SET0);
- outb( inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR);
+ outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR);
/* Check for underrrun! */
- if ( inb( iobase+AUDR) & AUDR_UNDR) {
- DEBUG( 0, __FUNCTION__ "(), Transmit underrun!\n");
+ if (inb(iobase+AUDR) & AUDR_UNDR) {
+ DEBUG(0, __FUNCTION__ "(), Transmit underrun!\n");
idev->stats.tx_errors++;
idev->stats.tx_fifo_errors++;
/* Clear bit, by writing 1 to it */
- outb( AUDR_UNDR, iobase+AUDR);
+ outb(AUDR_UNDR, iobase+AUDR);
} else
idev->stats.tx_packets++;
@@ -651,10 +651,10 @@
idev->media_busy = FALSE;
/* Tell the network layer, that we want more frames */
- mark_bh( NET_BH);
+ mark_bh(NET_BH);
/* Restore set */
- outb( set, iobase+SSR);
+ outb(set, iobase+SSR);
}
/*
@@ -664,7 +664,7 @@
* if it starts to receive a frame.
*
*/
-int w83977af_dma_receive( struct irda_device *idev)
+int w83977af_dma_receive(struct irda_device *idev)
{
int iobase;
__u8 set;
@@ -673,10 +673,10 @@
__u8 hcr;
#endif
- ASSERT( idev != NULL, return -1;);
- ASSERT( idev->magic == IRDA_DEVICE_MAGIC, return -1;);
+ ASSERT(idev != NULL, return -1;);
+ ASSERT(idev->magic == IRDA_DEVICE_MAGIC, return -1;);
- DEBUG( 0, __FUNCTION__ "\n");
+ DEBUG(0, __FUNCTION__ "\n");
iobase= idev->io.iobase;
@@ -697,8 +697,8 @@
set_dma_addr( idev->io.dma, virt_to_bus(idev->rx_buff.data));
set_dma_count( idev->io.dma, idev->rx_buff.truesize);
#else
- setup_dma( idev->io.dma, idev->rx_buff.data, idev->rx_buff.truesize,
- DMA_MODE_READ);
+ setup_dma(idev->io.dma, idev->rx_buff.data,
+ idev->rx_buff.truesize, DMA_MODE_READ);
#endif
/* driver->media_busy = FALSE; */
idev->io.direction = IO_RECV;
@@ -895,23 +895,23 @@
* Handle SIR interrupt
*
*/
-static __u8 w83977af_sir_interrupt( struct irda_device *idev, int isr)
+static __u8 w83977af_sir_interrupt(struct irda_device *idev, int isr)
{
int len;
int actual;
__u8 new_icr = 0;
- DEBUG( 4, __FUNCTION__ "(), isr=%#x\n", isr);
+ DEBUG(4, __FUNCTION__ "(), isr=%#x\n", isr);
/* Transmit FIFO low on data */
- if ( isr & ISR_TXTH_I) {
+ if (isr & ISR_TXTH_I) {
/* Write data left in transmit buffer */
len = idev->tx_buff.len - idev->tx_buff.offset;
- ASSERT( len > 0, return 0;);
- actual = w83977af_pio_write( idev->io.iobase,
- idev->tx_buff.head,
- len, idev->io.fifo_size);
+ ASSERT(len > 0, return 0;);
+ actual = w83977af_pio_write(idev->io.iobase,
+ idev->tx_buff.head,
+ len, idev->io.fifo_size);
idev->tx_buff.offset += actual;
idev->tx_buff.head += actual;
@@ -931,7 +931,7 @@
new_icr |= ICR_ETXTHI;
}
/* Check if transmission has completed */
- if ( isr & ISR_TXEMP_I) {
+ if (isr & ISR_TXEMP_I) {
/* Turn around and get ready to receive some data */
idev->io.direction = IO_RECV;
@@ -939,8 +939,8 @@
}
/* Rx FIFO threshold or timeout */
- if ( isr & ISR_RXTH_I) {
- w83977af_pio_receive( idev);
+ if (isr & ISR_RXTH_I) {
+ w83977af_pio_receive(idev);
/* Keep receiving */
new_icr |= ICR_ERBRI;
@@ -964,64 +964,64 @@
iobase = idev->io.iobase;
- set = inb( iobase+SSR);
+ set = inb(iobase+SSR);
/* End of frame detected in FIFO */
- if ( isr & (ISR_FEND_I|ISR_FSF_I)) {
- if ( w83977af_dma_receive_complete( idev)) {
+ if (isr & (ISR_FEND_I|ISR_FSF_I)) {
+ if (w83977af_dma_receive_complete(idev)) {
new_icr |= ICR_EFSFI;
} else {
/* DMA not finished yet */
/* Set timer value, resolution 1 ms */
- switch_bank( iobase, SET4);
- outb( 0x01, iobase+TMRL); /* 1 ms */
- outb( 0x00, iobase+TMRH);
+ switch_bank(iobase, SET4);
+ outb(0x01, iobase+TMRL); /* 1 ms */
+ outb(0x00, iobase+TMRH);
/* Start timer */
- outb( IR_MSL_EN_TMR, iobase+IR_MSL);
+ outb(IR_MSL_EN_TMR, iobase+IR_MSL);
new_icr |= ICR_ETMRI;
}
}
/* Timer finished */
- if ( isr & ISR_TMR_I) {
+ if (isr & ISR_TMR_I) {
/* Disable timer */
- switch_bank( iobase, SET4);
- outb( 0, iobase+IR_MSL);
+ switch_bank(iobase, SET4);
+ outb(0, iobase+IR_MSL);
/* Clear timer event */
/* switch_bank(iobase, SET0); */
/* outb( ASCR_CTE, iobase+ASCR); */
/* Check if this is a TX timer interrupt */
- if ( idev->io.direction == IO_XMIT) {
- w83977af_dma_write( idev, iobase);
+ if (idev->io.direction == IO_XMIT) {
+ w83977af_dma_write(idev, iobase);
new_icr |= ICR_EDMAI;
} else {
/* Check if DMA has now finished */
- w83977af_dma_receive_complete( idev);
+ w83977af_dma_receive_complete(idev);
new_icr |= ICR_EFSFI;
}
}
/* Finished with DMA */
- if ( isr & ISR_DMA_I) {
+ if (isr & ISR_DMA_I) {
w83977af_dma_xmit_complete( idev);
-
+
/* Check if there are more frames to be transmitted */
- if ( irda_device_txqueue_empty( idev)) {
+ if (irda_device_txqueue_empty( idev)) {
/* Prepare for receive */
- w83977af_dma_receive( idev);
+ w83977af_dma_receive(idev);
new_icr = ICR_EFSFI;
}
}
/* Restore set */
- outb( set, iobase+SSR);
+ outb(set, iobase+SSR);
return new_icr;
}
@@ -1039,9 +1039,9 @@
struct irda_device *idev = (struct irda_device *) dev_id;
- if ( idev == NULL) {
- printk( KERN_WARNING "%s: irq %d for unknown device.\n",
- driver_name, irq);
+ if (idev == NULL) {
+ printk(KERN_WARNING "%s: irq %d for unknown device.\n",
+ driver_name, irq);
return;
}
@@ -1050,24 +1050,24 @@
iobase = idev->io.iobase;
/* Save current bank */
- set = inb( iobase+SSR);
- switch_bank( iobase, SET0);
+ set = inb(iobase+SSR);
+ switch_bank(iobase, SET0);
- icr = inb( iobase+ICR);
- isr = inb( iobase+ISR) & icr; /* Mask out the interesting ones */
+ icr = inb(iobase+ICR);
+ isr = inb(iobase+ISR) & icr; /* Mask out the interesting ones */
- outb( 0, iobase+ICR); /* Disable interrupts */
+ outb(0, iobase+ICR); /* Disable interrupts */
- if ( isr) {
+ if (isr) {
/* Dispatch interrupt handler for the current speed */
if ( idev->io.baudrate > 115200)
- icr = w83977af_fir_interrupt( idev, isr);
+ icr = w83977af_fir_interrupt(idev, isr);
else
- icr = w83977af_sir_interrupt( idev, isr);
+ icr = w83977af_sir_interrupt(idev, isr);
}
- outb( icr, iobase+ICR); /* Restore (new) interrupts */
- outb( set, iobase+SSR); /* Restore bank register */
+ outb(icr, iobase+ICR); /* Restore (new) interrupts */
+ outb(set, iobase+SSR); /* Restore bank register */
idev->netdev.interrupt = 0;
}
@@ -1078,7 +1078,7 @@
* This function should put the current thread to sleep until all data
* have been sent, so it is safe to f.eks. change the speed.
*/
-static void w83977af_wait_until_sent( struct irda_device *idev)
+static void w83977af_wait_until_sent(struct irda_device *idev)
{
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(6);
@@ -1090,7 +1090,7 @@
* Return TRUE is we are currently receiving a frame
*
*/
-static int w83977af_is_receiving( struct irda_device *idev)
+static int w83977af_is_receiving(struct irda_device *idev)
{
int status = FALSE;
int iobase;
@@ -1103,15 +1103,15 @@
iobase = idev->io.iobase;
/* Check if rx FIFO is not empty */
- set = inb( iobase+SSR);
+ set = inb(iobase+SSR);
switch_bank( iobase, SET2);
if (( inb( iobase+RXFDTH) & 0x3f) != 0) {
/* We are receiving something */
status = TRUE;
}
- outb( set, iobase+SSR);
+ outb(set, iobase+SSR);
} else
- status = ( idev->rx_buff.state != OUTSIDE_FRAME);
+ status = (idev->rx_buff.state != OUTSIDE_FRAME);
return status;
}
@@ -1124,7 +1124,7 @@
*/
static int w83977af_net_init( struct device *dev)
{
- DEBUG( 0, __FUNCTION__ "()\n");
+ DEBUG(0, __FUNCTION__ "()\n");
/* Set up to be a normal IrDA network device driver */
irda_device_setup( dev);
@@ -1147,18 +1147,18 @@
int iobase;
__u8 set;
- DEBUG( 0, __FUNCTION__ "()\n");
+ DEBUG(0, __FUNCTION__ "()\n");
- ASSERT( dev != NULL, return -1;);
+ ASSERT(dev != NULL, return -1;);
idev = (struct irda_device *) dev->priv;
- ASSERT( idev != NULL, return 0;);
- ASSERT( idev->magic == IRDA_DEVICE_MAGIC, return 0;);
+ ASSERT(idev != NULL, return 0;);
+ ASSERT(idev->magic == IRDA_DEVICE_MAGIC, return 0;);
iobase = idev->io.iobase;
- if (request_irq( idev->io.irq, w83977af_interrupt, 0, idev->name,
- (void *) idev)) {
+ if (request_irq(idev->io.irq, w83977af_interrupt, 0, idev->name,
+ (void *) idev)) {
return -EAGAIN;
}
/*
@@ -1166,7 +1166,7 @@
* and clean up on failure.
*/
if (request_dma(idev->io.dma, idev->name)) {
- free_irq( idev->io.irq, idev);
+ free_irq(idev->io.irq, idev);
return -EAGAIN;
}
@@ -1176,11 +1176,11 @@
dev->start = 1;
/* Save current set */
- set = inb( iobase+SSR);
+ set = inb(iobase+SSR);
/* Enable some interrupts so we can receive frames again */
switch_bank(iobase, SET0);
- if ( idev->io.baudrate > 115200) {
+ if (idev->io.baudrate > 115200) {
outb( ICR_EFSFI, iobase+ICR);
w83977af_dma_receive( idev);
} else
@@ -1250,9 +1250,7 @@
*/
int init_module(void)
{
- w83977af_init();
-
- return(0);
+ return w83977af_init();
}
/*
@@ -1265,5 +1263,4 @@
{
w83977af_cleanup();
}
-
-#endif
+#endif /* MODULE */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)