Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /********************************************************************* |
| 2 | * |
| 3 | * Filename: w83977af_ir.c |
| 4 | * Version: 1.0 |
| 5 | * Description: FIR driver for the Winbond W83977AF Super I/O chip |
| 6 | * Status: Experimental. |
| 7 | * Author: Paul VanderSpek |
| 8 | * Created at: Wed Nov 4 11:46:16 1998 |
| 9 | * Modified at: Fri Jan 28 12:10:59 2000 |
| 10 | * Modified by: Dag Brattli <dagb@cs.uit.no> |
| 11 | * |
| 12 | * Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no> |
| 13 | * Copyright (c) 1998-1999 Rebel.com |
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU General Public License as |
| 17 | * published by the Free Software Foundation; either version 2 of |
| 18 | * the License, or (at your option) any later version. |
| 19 | * |
| 20 | * Neither Paul VanderSpek nor Rebel.com admit liability nor provide |
| 21 | * warranty for any of this software. This material is provided "AS-IS" |
| 22 | * and at no charge. |
| 23 | * |
| 24 | * If you find bugs in this file, its very likely that the same bug |
| 25 | * will also be in pc87108.c since the implementations are quite |
| 26 | * similar. |
| 27 | * |
| 28 | * Notice that all functions that needs to access the chip in _any_ |
| 29 | * way, must save BSR register on entry, and restore it on exit. |
| 30 | * It is _very_ important to follow this policy! |
| 31 | * |
| 32 | * __u8 bank; |
| 33 | * |
| 34 | * bank = inb( iobase+BSR); |
| 35 | * |
| 36 | * do_your_stuff_here(); |
| 37 | * |
| 38 | * outb( bank, iobase+BSR); |
| 39 | * |
| 40 | ********************************************************************/ |
| 41 | |
| 42 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <linux/kernel.h> |
| 44 | #include <linux/types.h> |
| 45 | #include <linux/skbuff.h> |
| 46 | #include <linux/netdevice.h> |
| 47 | #include <linux/ioport.h> |
| 48 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include <linux/init.h> |
Alexey Dobriyan | a6b7a40 | 2011-06-06 10:43:46 +0000 | [diff] [blame] | 50 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include <linux/rtnetlink.h> |
| 52 | #include <linux/dma-mapping.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 53 | #include <linux/gfp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | #include <asm/io.h> |
| 56 | #include <asm/dma.h> |
| 57 | #include <asm/byteorder.h> |
| 58 | |
| 59 | #include <net/irda/irda.h> |
| 60 | #include <net/irda/wrapper.h> |
| 61 | #include <net/irda/irda_device.h> |
| 62 | #include "w83977af.h" |
| 63 | #include "w83977af_ir.h" |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #define CONFIG_USE_W977_PNP /* Currently needed */ |
| 66 | #define PIO_MAX_SPEED 115200 |
| 67 | |
| 68 | static char *driver_name = "w83977af_ir"; |
| 69 | static int qos_mtt_bits = 0x07; /* 1 ms or more */ |
| 70 | |
| 71 | #define CHIP_IO_EXTENT 8 |
| 72 | |
| 73 | static unsigned int io[] = { 0x180, ~0, ~0, ~0 }; |
| 74 | #ifdef CONFIG_ARCH_NETWINDER /* Adjust to NetWinder differences */ |
| 75 | static unsigned int irq[] = { 6, 0, 0, 0 }; |
| 76 | #else |
| 77 | static unsigned int irq[] = { 11, 0, 0, 0 }; |
| 78 | #endif |
| 79 | static unsigned int dma[] = { 1, 0, 0, 0 }; |
| 80 | static unsigned int efbase[] = { W977_EFIO_BASE, W977_EFIO2_BASE }; |
| 81 | static unsigned int efio = W977_EFIO_BASE; |
| 82 | |
| 83 | static struct w83977af_ir *dev_self[] = { NULL, NULL, NULL, NULL}; |
| 84 | |
| 85 | /* Some prototypes */ |
| 86 | static int w83977af_open(int i, unsigned int iobase, unsigned int irq, |
| 87 | unsigned int dma); |
| 88 | static int w83977af_close(struct w83977af_ir *self); |
| 89 | static int w83977af_probe(int iobase, int irq, int dma); |
| 90 | static int w83977af_dma_receive(struct w83977af_ir *self); |
| 91 | static int w83977af_dma_receive_complete(struct w83977af_ir *self); |
Stephen Hemminger | 6518bbb | 2009-08-31 19:50:50 +0000 | [diff] [blame] | 92 | static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, |
| 93 | struct net_device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size); |
| 95 | static void w83977af_dma_write(struct w83977af_ir *self, int iobase); |
| 96 | static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed); |
| 97 | static int w83977af_is_receiving(struct w83977af_ir *self); |
| 98 | |
| 99 | static int w83977af_net_open(struct net_device *dev); |
| 100 | static int w83977af_net_close(struct net_device *dev); |
| 101 | static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
| 103 | /* |
| 104 | * Function w83977af_init () |
| 105 | * |
| 106 | * Initialize chip. Just try to find out how many chips we are dealing with |
| 107 | * and where they are |
| 108 | */ |
| 109 | static int __init w83977af_init(void) |
| 110 | { |
| 111 | int i; |
| 112 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 113 | IRDA_DEBUG(0, "%s()\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
Roel Kluin | 5d5ceb8 | 2009-08-06 13:06:03 +0000 | [diff] [blame] | 115 | for (i=0; i < ARRAY_SIZE(dev_self) && io[i] < 2000; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | if (w83977af_open(i, io[i], irq[i], dma[i]) == 0) |
| 117 | return 0; |
| 118 | } |
| 119 | return -ENODEV; |
| 120 | } |
| 121 | |
| 122 | /* |
| 123 | * Function w83977af_cleanup () |
| 124 | * |
| 125 | * Close all configured chips |
| 126 | * |
| 127 | */ |
| 128 | static void __exit w83977af_cleanup(void) |
| 129 | { |
| 130 | int i; |
| 131 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 132 | IRDA_DEBUG(4, "%s()\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
Bjorn Helgaas | 9c3bd68 | 2006-08-15 00:05:38 -0700 | [diff] [blame] | 134 | for (i=0; i < ARRAY_SIZE(dev_self); i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | if (dev_self[i]) |
| 136 | w83977af_close(dev_self[i]); |
| 137 | } |
| 138 | } |
| 139 | |
Stephen Hemminger | 4113a1a | 2009-03-20 19:35:38 +0000 | [diff] [blame] | 140 | static const struct net_device_ops w83977_netdev_ops = { |
| 141 | .ndo_open = w83977af_net_open, |
| 142 | .ndo_stop = w83977af_net_close, |
| 143 | .ndo_start_xmit = w83977af_hard_xmit, |
| 144 | .ndo_do_ioctl = w83977af_net_ioctl, |
| 145 | }; |
| 146 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | /* |
| 148 | * Function w83977af_open (iobase, irq) |
| 149 | * |
| 150 | * Open driver instance |
| 151 | * |
| 152 | */ |
Hannes Eder | 0e49e64 | 2008-12-26 00:03:19 -0800 | [diff] [blame] | 153 | static int w83977af_open(int i, unsigned int iobase, unsigned int irq, |
| 154 | unsigned int dma) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | { |
| 156 | struct net_device *dev; |
| 157 | struct w83977af_ir *self; |
| 158 | int err; |
| 159 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 160 | IRDA_DEBUG(0, "%s()\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
| 162 | /* Lock the port that we need */ |
| 163 | if (!request_region(iobase, CHIP_IO_EXTENT, driver_name)) { |
| 164 | IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n", |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 165 | __func__ , iobase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | return -ENODEV; |
| 167 | } |
| 168 | |
| 169 | if (w83977af_probe(iobase, irq, dma) == -1) { |
| 170 | err = -1; |
| 171 | goto err_out; |
| 172 | } |
| 173 | /* |
| 174 | * Allocate new instance of the driver |
| 175 | */ |
| 176 | dev = alloc_irdadev(sizeof(struct w83977af_ir)); |
| 177 | if (dev == NULL) { |
| 178 | printk( KERN_ERR "IrDA: Can't allocate memory for " |
| 179 | "IrDA control block!\n"); |
| 180 | err = -ENOMEM; |
| 181 | goto err_out; |
| 182 | } |
| 183 | |
Wang Chen | 4cf1653 | 2008-11-12 23:38:14 -0800 | [diff] [blame] | 184 | self = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | spin_lock_init(&self->lock); |
| 186 | |
| 187 | |
| 188 | /* Initialize IO */ |
| 189 | self->io.fir_base = iobase; |
| 190 | self->io.irq = irq; |
| 191 | self->io.fir_ext = CHIP_IO_EXTENT; |
| 192 | self->io.dma = dma; |
| 193 | self->io.fifo_size = 32; |
| 194 | |
| 195 | /* Initialize QoS for this device */ |
| 196 | irda_init_max_qos_capabilies(&self->qos); |
| 197 | |
| 198 | /* The only value we must override it the baudrate */ |
| 199 | |
| 200 | /* FIXME: The HP HDLS-1100 does not support 1152000! */ |
| 201 | self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600| |
| 202 | IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8); |
| 203 | |
| 204 | /* The HP HDLS-1100 needs 1 ms according to the specs */ |
| 205 | self->qos.min_turn_time.bits = qos_mtt_bits; |
| 206 | irda_qos_bits_to_value(&self->qos); |
| 207 | |
| 208 | /* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */ |
| 209 | self->rx_buff.truesize = 14384; |
| 210 | self->tx_buff.truesize = 4000; |
| 211 | |
| 212 | /* Allocate memory if needed */ |
| 213 | self->rx_buff.head = |
Joe Perches | ede23fa | 2013-08-26 22:45:23 -0700 | [diff] [blame] | 214 | dma_zalloc_coherent(NULL, self->rx_buff.truesize, |
| 215 | &self->rx_buff_dma, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | if (self->rx_buff.head == NULL) { |
| 217 | err = -ENOMEM; |
| 218 | goto err_out1; |
| 219 | } |
| 220 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | self->tx_buff.head = |
Joe Perches | ede23fa | 2013-08-26 22:45:23 -0700 | [diff] [blame] | 222 | dma_zalloc_coherent(NULL, self->tx_buff.truesize, |
| 223 | &self->tx_buff_dma, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | if (self->tx_buff.head == NULL) { |
| 225 | err = -ENOMEM; |
| 226 | goto err_out2; |
| 227 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | self->rx_buff.in_frame = FALSE; |
| 230 | self->rx_buff.state = OUTSIDE_FRAME; |
| 231 | self->tx_buff.data = self->tx_buff.head; |
| 232 | self->rx_buff.data = self->rx_buff.head; |
| 233 | self->netdev = dev; |
| 234 | |
Stephen Hemminger | 4113a1a | 2009-03-20 19:35:38 +0000 | [diff] [blame] | 235 | dev->netdev_ops = &w83977_netdev_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
| 237 | err = register_netdev(dev); |
| 238 | if (err) { |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 239 | IRDA_ERROR("%s(), register_netdevice() failed!\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | goto err_out3; |
| 241 | } |
| 242 | IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name); |
| 243 | |
| 244 | /* Need to store self somewhere */ |
| 245 | dev_self[i] = self; |
| 246 | |
| 247 | return 0; |
| 248 | err_out3: |
| 249 | dma_free_coherent(NULL, self->tx_buff.truesize, |
| 250 | self->tx_buff.head, self->tx_buff_dma); |
| 251 | err_out2: |
| 252 | dma_free_coherent(NULL, self->rx_buff.truesize, |
| 253 | self->rx_buff.head, self->rx_buff_dma); |
| 254 | err_out1: |
| 255 | free_netdev(dev); |
| 256 | err_out: |
| 257 | release_region(iobase, CHIP_IO_EXTENT); |
| 258 | return err; |
| 259 | } |
| 260 | |
| 261 | /* |
| 262 | * Function w83977af_close (self) |
| 263 | * |
| 264 | * Close driver instance |
| 265 | * |
| 266 | */ |
| 267 | static int w83977af_close(struct w83977af_ir *self) |
| 268 | { |
| 269 | int iobase; |
| 270 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 271 | IRDA_DEBUG(0, "%s()\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
| 273 | iobase = self->io.fir_base; |
| 274 | |
| 275 | #ifdef CONFIG_USE_W977_PNP |
| 276 | /* enter PnP configuration mode */ |
| 277 | w977_efm_enter(efio); |
| 278 | |
| 279 | w977_select_device(W977_DEVICE_IR, efio); |
| 280 | |
| 281 | /* Deactivate device */ |
| 282 | w977_write_reg(0x30, 0x00, efio); |
| 283 | |
| 284 | w977_efm_exit(efio); |
| 285 | #endif /* CONFIG_USE_W977_PNP */ |
| 286 | |
| 287 | /* Remove netdevice */ |
| 288 | unregister_netdev(self->netdev); |
| 289 | |
| 290 | /* Release the PORT that this driver is using */ |
| 291 | IRDA_DEBUG(0 , "%s(), Releasing Region %03x\n", |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 292 | __func__ , self->io.fir_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | release_region(self->io.fir_base, self->io.fir_ext); |
| 294 | |
| 295 | if (self->tx_buff.head) |
| 296 | dma_free_coherent(NULL, self->tx_buff.truesize, |
| 297 | self->tx_buff.head, self->tx_buff_dma); |
| 298 | |
| 299 | if (self->rx_buff.head) |
| 300 | dma_free_coherent(NULL, self->rx_buff.truesize, |
| 301 | self->rx_buff.head, self->rx_buff_dma); |
| 302 | |
| 303 | free_netdev(self->netdev); |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
Hannes Eder | 0e49e64 | 2008-12-26 00:03:19 -0800 | [diff] [blame] | 308 | static int w83977af_probe(int iobase, int irq, int dma) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | { |
| 310 | int version; |
| 311 | int i; |
| 312 | |
| 313 | for (i=0; i < 2; i++) { |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 314 | IRDA_DEBUG( 0, "%s()\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | #ifdef CONFIG_USE_W977_PNP |
| 316 | /* Enter PnP configuration mode */ |
| 317 | w977_efm_enter(efbase[i]); |
| 318 | |
| 319 | w977_select_device(W977_DEVICE_IR, efbase[i]); |
| 320 | |
| 321 | /* Configure PnP port, IRQ, and DMA channel */ |
| 322 | w977_write_reg(0x60, (iobase >> 8) & 0xff, efbase[i]); |
| 323 | w977_write_reg(0x61, (iobase) & 0xff, efbase[i]); |
| 324 | |
| 325 | w977_write_reg(0x70, irq, efbase[i]); |
| 326 | #ifdef CONFIG_ARCH_NETWINDER |
| 327 | /* Netwinder uses 1 higher than Linux */ |
| 328 | w977_write_reg(0x74, dma+1, efbase[i]); |
| 329 | #else |
| 330 | w977_write_reg(0x74, dma, efbase[i]); |
Paul Bolle | 528b971 | 2014-05-04 13:03:12 +0200 | [diff] [blame^] | 331 | #endif /* CONFIG_ARCH_NETWINDER */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | w977_write_reg(0x75, 0x04, efbase[i]); /* Disable Tx DMA */ |
| 333 | |
| 334 | /* Set append hardware CRC, enable IR bank selection */ |
| 335 | w977_write_reg(0xf0, APEDCRC|ENBNKSEL, efbase[i]); |
| 336 | |
| 337 | /* Activate device */ |
| 338 | w977_write_reg(0x30, 0x01, efbase[i]); |
| 339 | |
| 340 | w977_efm_exit(efbase[i]); |
| 341 | #endif /* CONFIG_USE_W977_PNP */ |
| 342 | /* Disable Advanced mode */ |
| 343 | switch_bank(iobase, SET2); |
| 344 | outb(iobase+2, 0x00); |
| 345 | |
| 346 | /* Turn on UART (global) interrupts */ |
| 347 | switch_bank(iobase, SET0); |
| 348 | outb(HCR_EN_IRQ, iobase+HCR); |
| 349 | |
| 350 | /* Switch to advanced mode */ |
| 351 | switch_bank(iobase, SET2); |
| 352 | outb(inb(iobase+ADCR1) | ADCR1_ADV_SL, iobase+ADCR1); |
| 353 | |
| 354 | /* Set default IR-mode */ |
| 355 | switch_bank(iobase, SET0); |
| 356 | outb(HCR_SIR, iobase+HCR); |
| 357 | |
| 358 | /* Read the Advanced IR ID */ |
| 359 | switch_bank(iobase, SET3); |
| 360 | version = inb(iobase+AUID); |
| 361 | |
| 362 | /* Should be 0x1? */ |
| 363 | if (0x10 == (version & 0xf0)) { |
| 364 | efio = efbase[i]; |
| 365 | |
| 366 | /* Set FIFO size to 32 */ |
| 367 | switch_bank(iobase, SET2); |
| 368 | outb(ADCR2_RXFS32|ADCR2_TXFS32, iobase+ADCR2); |
| 369 | |
| 370 | /* Set FIFO threshold to TX17, RX16 */ |
| 371 | switch_bank(iobase, SET0); |
| 372 | outb(UFR_RXTL|UFR_TXTL|UFR_TXF_RST|UFR_RXF_RST| |
| 373 | UFR_EN_FIFO,iobase+UFR); |
| 374 | |
| 375 | /* Receiver frame length */ |
| 376 | switch_bank(iobase, SET4); |
| 377 | outb(2048 & 0xff, iobase+6); |
| 378 | outb((2048 >> 8) & 0x1f, iobase+7); |
| 379 | |
| 380 | /* |
| 381 | * Init HP HSDL-1100 transceiver. |
| 382 | * |
| 383 | * Set IRX_MSL since we have 2 * receive paths IRRX, |
| 384 | * and IRRXH. Clear IRSL0D since we want IRSL0 * to |
| 385 | * be a input pin used for IRRXH |
| 386 | * |
| 387 | * IRRX pin 37 connected to receiver |
| 388 | * IRTX pin 38 connected to transmitter |
| 389 | * FIRRX pin 39 connected to receiver (IRSL0) |
| 390 | * CIRRX pin 40 connected to pin 37 |
| 391 | */ |
| 392 | switch_bank(iobase, SET7); |
| 393 | outb(0x40, iobase+7); |
| 394 | |
| 395 | IRDA_MESSAGE("W83977AF (IR) driver loaded. " |
| 396 | "Version: 0x%02x\n", version); |
| 397 | |
| 398 | return 0; |
| 399 | } else { |
| 400 | /* Try next extented function register address */ |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 401 | IRDA_DEBUG( 0, "%s(), Wrong chip version", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | } |
| 403 | } |
| 404 | return -1; |
| 405 | } |
| 406 | |
Hannes Eder | 0e49e64 | 2008-12-26 00:03:19 -0800 | [diff] [blame] | 407 | static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | { |
| 409 | int ir_mode = HCR_SIR; |
| 410 | int iobase; |
| 411 | __u8 set; |
| 412 | |
| 413 | iobase = self->io.fir_base; |
| 414 | |
| 415 | /* Update accounting for new speed */ |
| 416 | self->io.speed = speed; |
| 417 | |
| 418 | /* Save current bank */ |
| 419 | set = inb(iobase+SSR); |
| 420 | |
| 421 | /* Disable interrupts */ |
| 422 | switch_bank(iobase, SET0); |
| 423 | outb(0, iobase+ICR); |
| 424 | |
| 425 | /* Select Set 2 */ |
| 426 | switch_bank(iobase, SET2); |
| 427 | outb(0x00, iobase+ABHL); |
| 428 | |
| 429 | switch (speed) { |
| 430 | case 9600: outb(0x0c, iobase+ABLL); break; |
| 431 | case 19200: outb(0x06, iobase+ABLL); break; |
| 432 | case 38400: outb(0x03, iobase+ABLL); break; |
| 433 | case 57600: outb(0x02, iobase+ABLL); break; |
| 434 | case 115200: outb(0x01, iobase+ABLL); break; |
| 435 | case 576000: |
| 436 | ir_mode = HCR_MIR_576; |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 437 | IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | break; |
| 439 | case 1152000: |
| 440 | ir_mode = HCR_MIR_1152; |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 441 | IRDA_DEBUG(0, "%s(), handling baud of 1152000\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | break; |
| 443 | case 4000000: |
| 444 | ir_mode = HCR_FIR; |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 445 | IRDA_DEBUG(0, "%s(), handling baud of 4000000\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | break; |
| 447 | default: |
| 448 | ir_mode = HCR_FIR; |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 449 | IRDA_DEBUG(0, "%s(), unknown baud rate of %d\n", __func__ , speed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | break; |
| 451 | } |
| 452 | |
| 453 | /* Set speed mode */ |
| 454 | switch_bank(iobase, SET0); |
| 455 | outb(ir_mode, iobase+HCR); |
| 456 | |
| 457 | /* set FIFO size to 32 */ |
| 458 | switch_bank(iobase, SET2); |
| 459 | outb(ADCR2_RXFS32|ADCR2_TXFS32, iobase+ADCR2); |
| 460 | |
| 461 | /* set FIFO threshold to TX17, RX16 */ |
| 462 | switch_bank(iobase, SET0); |
| 463 | outb(0x00, iobase+UFR); /* Reset */ |
| 464 | outb(UFR_EN_FIFO, iobase+UFR); /* First we must enable FIFO */ |
| 465 | outb(0xa7, iobase+UFR); |
| 466 | |
| 467 | netif_wake_queue(self->netdev); |
| 468 | |
| 469 | /* Enable some interrupts so we can receive frames */ |
| 470 | switch_bank(iobase, SET0); |
| 471 | if (speed > PIO_MAX_SPEED) { |
| 472 | outb(ICR_EFSFI, iobase+ICR); |
| 473 | w83977af_dma_receive(self); |
| 474 | } else |
| 475 | outb(ICR_ERBRI, iobase+ICR); |
| 476 | |
| 477 | /* Restore SSR */ |
| 478 | outb(set, iobase+SSR); |
| 479 | } |
| 480 | |
| 481 | /* |
| 482 | * Function w83977af_hard_xmit (skb, dev) |
| 483 | * |
| 484 | * Sets up a DMA transfer to send the current frame. |
| 485 | * |
| 486 | */ |
Stephen Hemminger | 6518bbb | 2009-08-31 19:50:50 +0000 | [diff] [blame] | 487 | static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, |
| 488 | struct net_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | { |
| 490 | struct w83977af_ir *self; |
| 491 | __s32 speed; |
| 492 | int iobase; |
| 493 | __u8 set; |
| 494 | int mtt; |
| 495 | |
Wang Chen | 4cf1653 | 2008-11-12 23:38:14 -0800 | [diff] [blame] | 496 | self = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | |
| 498 | iobase = self->io.fir_base; |
| 499 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 500 | IRDA_DEBUG(4, "%s(%ld), skb->len=%d\n", __func__ , jiffies, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | (int) skb->len); |
| 502 | |
| 503 | /* Lock transmit buffer */ |
| 504 | netif_stop_queue(dev); |
| 505 | |
| 506 | /* Check if we need to change the speed */ |
| 507 | speed = irda_get_next_speed(skb); |
| 508 | if ((speed != self->io.speed) && (speed != -1)) { |
| 509 | /* Check for empty frame */ |
| 510 | if (!skb->len) { |
| 511 | w83977af_change_speed(self, speed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | dev_kfree_skb(skb); |
Patrick McHardy | 6ed1065 | 2009-06-23 06:03:08 +0000 | [diff] [blame] | 513 | return NETDEV_TX_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | } else |
| 515 | self->new_speed = speed; |
| 516 | } |
| 517 | |
| 518 | /* Save current set */ |
| 519 | set = inb(iobase+SSR); |
| 520 | |
| 521 | /* Decide if we should use PIO or DMA transfer */ |
| 522 | if (self->io.speed > PIO_MAX_SPEED) { |
| 523 | self->tx_buff.data = self->tx_buff.head; |
Arnaldo Carvalho de Melo | d626f62 | 2007-03-27 18:55:52 -0300 | [diff] [blame] | 524 | skb_copy_from_linear_data(skb, self->tx_buff.data, skb->len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | self->tx_buff.len = skb->len; |
| 526 | |
| 527 | mtt = irda_get_mtt(skb); |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 528 | IRDA_DEBUG(4, "%s(%ld), mtt=%d\n", __func__ , jiffies, mtt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | if (mtt) |
| 530 | udelay(mtt); |
| 531 | |
| 532 | /* Enable DMA interrupt */ |
| 533 | switch_bank(iobase, SET0); |
| 534 | outb(ICR_EDMAI, iobase+ICR); |
| 535 | w83977af_dma_write(self, iobase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | } else { |
| 537 | self->tx_buff.data = self->tx_buff.head; |
| 538 | self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data, |
| 539 | self->tx_buff.truesize); |
| 540 | |
| 541 | /* Add interrupt on tx low level (will fire immediately) */ |
| 542 | switch_bank(iobase, SET0); |
| 543 | outb(ICR_ETXTHI, iobase+ICR); |
| 544 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | dev_kfree_skb(skb); |
| 546 | |
| 547 | /* Restore set register */ |
| 548 | outb(set, iobase+SSR); |
| 549 | |
Patrick McHardy | 6ed1065 | 2009-06-23 06:03:08 +0000 | [diff] [blame] | 550 | return NETDEV_TX_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | /* |
| 554 | * Function w83977af_dma_write (self, iobase) |
| 555 | * |
| 556 | * Send frame using DMA |
| 557 | * |
| 558 | */ |
| 559 | static void w83977af_dma_write(struct w83977af_ir *self, int iobase) |
| 560 | { |
| 561 | __u8 set; |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 562 | IRDA_DEBUG(4, "%s(), len=%d\n", __func__ , self->tx_buff.len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | |
| 564 | /* Save current set */ |
| 565 | set = inb(iobase+SSR); |
| 566 | |
| 567 | /* Disable DMA */ |
| 568 | switch_bank(iobase, SET0); |
| 569 | outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR); |
| 570 | |
| 571 | /* Choose transmit DMA channel */ |
| 572 | switch_bank(iobase, SET2); |
| 573 | outb(ADCR1_D_CHSW|/*ADCR1_DMA_F|*/ADCR1_ADV_SL, iobase+ADCR1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len, |
| 575 | DMA_MODE_WRITE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | self->io.direction = IO_XMIT; |
| 577 | |
| 578 | /* Enable DMA */ |
| 579 | switch_bank(iobase, SET0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | outb(inb(iobase+HCR) | HCR_EN_DMA | HCR_TX_WT, iobase+HCR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | |
| 582 | /* Restore set register */ |
| 583 | outb(set, iobase+SSR); |
| 584 | } |
| 585 | |
| 586 | /* |
| 587 | * Function w83977af_pio_write (iobase, buf, len, fifo_size) |
| 588 | * |
| 589 | * |
| 590 | * |
| 591 | */ |
| 592 | static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size) |
| 593 | { |
| 594 | int actual = 0; |
| 595 | __u8 set; |
| 596 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 597 | IRDA_DEBUG(4, "%s()\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | |
| 599 | /* Save current bank */ |
| 600 | set = inb(iobase+SSR); |
| 601 | |
| 602 | switch_bank(iobase, SET0); |
| 603 | if (!(inb_p(iobase+USR) & USR_TSRE)) { |
| 604 | IRDA_DEBUG(4, |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 605 | "%s(), warning, FIFO not empty yet!\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | |
| 607 | fifo_size -= 17; |
| 608 | IRDA_DEBUG(4, "%s(), %d bytes left in tx fifo\n", |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 609 | __func__ , fifo_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | /* Fill FIFO with current frame */ |
| 613 | while ((fifo_size-- > 0) && (actual < len)) { |
| 614 | /* Transmit next byte */ |
| 615 | outb(buf[actual++], iobase+TBR); |
| 616 | } |
| 617 | |
| 618 | IRDA_DEBUG(4, "%s(), fifo_size %d ; %d sent of %d\n", |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 619 | __func__ , fifo_size, actual, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | |
| 621 | /* Restore bank */ |
| 622 | outb(set, iobase+SSR); |
| 623 | |
| 624 | return actual; |
| 625 | } |
| 626 | |
| 627 | /* |
| 628 | * Function w83977af_dma_xmit_complete (self) |
| 629 | * |
| 630 | * The transfer of a frame in finished. So do the necessary things |
| 631 | * |
| 632 | * |
| 633 | */ |
| 634 | static void w83977af_dma_xmit_complete(struct w83977af_ir *self) |
| 635 | { |
| 636 | int iobase; |
| 637 | __u8 set; |
| 638 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 639 | IRDA_DEBUG(4, "%s(%ld)\n", __func__ , jiffies); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | |
| 641 | IRDA_ASSERT(self != NULL, return;); |
| 642 | |
| 643 | iobase = self->io.fir_base; |
| 644 | |
| 645 | /* Save current set */ |
| 646 | set = inb(iobase+SSR); |
| 647 | |
| 648 | /* Disable DMA */ |
| 649 | switch_bank(iobase, SET0); |
| 650 | outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR); |
| 651 | |
Justin P. Mattock | 42b2aa8 | 2011-11-28 20:31:00 -0800 | [diff] [blame] | 652 | /* Check for underrun! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | if (inb(iobase+AUDR) & AUDR_UNDR) { |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 654 | IRDA_DEBUG(0, "%s(), Transmit underrun!\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 656 | self->netdev->stats.tx_errors++; |
| 657 | self->netdev->stats.tx_fifo_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
| 659 | /* Clear bit, by writing 1 to it */ |
| 660 | outb(AUDR_UNDR, iobase+AUDR); |
| 661 | } else |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 662 | self->netdev->stats.tx_packets++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | |
| 664 | |
| 665 | if (self->new_speed) { |
| 666 | w83977af_change_speed(self, self->new_speed); |
| 667 | self->new_speed = 0; |
| 668 | } |
| 669 | |
| 670 | /* Unlock tx_buff and request another frame */ |
| 671 | /* Tell the network layer, that we want more frames */ |
| 672 | netif_wake_queue(self->netdev); |
| 673 | |
| 674 | /* Restore set */ |
| 675 | outb(set, iobase+SSR); |
| 676 | } |
| 677 | |
| 678 | /* |
| 679 | * Function w83977af_dma_receive (self) |
| 680 | * |
| 681 | * Get ready for receiving a frame. The device will initiate a DMA |
| 682 | * if it starts to receive a frame. |
| 683 | * |
| 684 | */ |
Hannes Eder | 0e49e64 | 2008-12-26 00:03:19 -0800 | [diff] [blame] | 685 | static int w83977af_dma_receive(struct w83977af_ir *self) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | { |
| 687 | int iobase; |
| 688 | __u8 set; |
Paul Bolle | 528b971 | 2014-05-04 13:03:12 +0200 | [diff] [blame^] | 689 | #ifdef CONFIG_ARCH_NETWINDER |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | unsigned long flags; |
| 691 | __u8 hcr; |
| 692 | #endif |
| 693 | IRDA_ASSERT(self != NULL, return -1;); |
| 694 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 695 | IRDA_DEBUG(4, "%s\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | |
| 697 | iobase= self->io.fir_base; |
| 698 | |
| 699 | /* Save current set */ |
| 700 | set = inb(iobase+SSR); |
| 701 | |
| 702 | /* Disable DMA */ |
| 703 | switch_bank(iobase, SET0); |
| 704 | outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR); |
| 705 | |
| 706 | /* Choose DMA Rx, DMA Fairness, and Advanced mode */ |
| 707 | switch_bank(iobase, SET2); |
| 708 | outb((inb(iobase+ADCR1) & ~ADCR1_D_CHSW)/*|ADCR1_DMA_F*/|ADCR1_ADV_SL, |
| 709 | iobase+ADCR1); |
| 710 | |
| 711 | self->io.direction = IO_RECV; |
| 712 | self->rx_buff.data = self->rx_buff.head; |
| 713 | |
Paul Bolle | 528b971 | 2014-05-04 13:03:12 +0200 | [diff] [blame^] | 714 | #ifdef CONFIG_ARCH_NETWINDER |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | spin_lock_irqsave(&self->lock, flags); |
| 716 | |
| 717 | disable_dma(self->io.dma); |
| 718 | clear_dma_ff(self->io.dma); |
| 719 | set_dma_mode(self->io.dma, DMA_MODE_READ); |
| 720 | set_dma_addr(self->io.dma, self->rx_buff_dma); |
| 721 | set_dma_count(self->io.dma, self->rx_buff.truesize); |
| 722 | #else |
| 723 | irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize, |
| 724 | DMA_MODE_READ); |
| 725 | #endif |
| 726 | /* |
| 727 | * Reset Rx FIFO. This will also flush the ST_FIFO, it's very |
| 728 | * important that we don't reset the Tx FIFO since it might not |
| 729 | * be finished transmitting yet |
| 730 | */ |
| 731 | switch_bank(iobase, SET0); |
| 732 | outb(UFR_RXTL|UFR_TXTL|UFR_RXF_RST|UFR_EN_FIFO, iobase+UFR); |
| 733 | self->st_fifo.len = self->st_fifo.tail = self->st_fifo.head = 0; |
| 734 | |
| 735 | /* Enable DMA */ |
| 736 | switch_bank(iobase, SET0); |
Paul Bolle | 528b971 | 2014-05-04 13:03:12 +0200 | [diff] [blame^] | 737 | #ifdef CONFIG_ARCH_NETWINDER |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | hcr = inb(iobase+HCR); |
| 739 | outb(hcr | HCR_EN_DMA, iobase+HCR); |
| 740 | enable_dma(self->io.dma); |
| 741 | spin_unlock_irqrestore(&self->lock, flags); |
| 742 | #else |
| 743 | outb(inb(iobase+HCR) | HCR_EN_DMA, iobase+HCR); |
| 744 | #endif |
| 745 | /* Restore set */ |
| 746 | outb(set, iobase+SSR); |
| 747 | |
| 748 | return 0; |
| 749 | } |
| 750 | |
| 751 | /* |
| 752 | * Function w83977af_receive_complete (self) |
| 753 | * |
| 754 | * Finished with receiving a frame |
| 755 | * |
| 756 | */ |
Hannes Eder | 0e49e64 | 2008-12-26 00:03:19 -0800 | [diff] [blame] | 757 | static int w83977af_dma_receive_complete(struct w83977af_ir *self) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | { |
| 759 | struct sk_buff *skb; |
| 760 | struct st_fifo *st_fifo; |
| 761 | int len; |
| 762 | int iobase; |
| 763 | __u8 set; |
| 764 | __u8 status; |
| 765 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 766 | IRDA_DEBUG(4, "%s\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | |
| 768 | st_fifo = &self->st_fifo; |
| 769 | |
| 770 | iobase = self->io.fir_base; |
| 771 | |
| 772 | /* Save current set */ |
| 773 | set = inb(iobase+SSR); |
| 774 | |
| 775 | iobase = self->io.fir_base; |
| 776 | |
| 777 | /* Read status FIFO */ |
| 778 | switch_bank(iobase, SET5); |
| 779 | while ((status = inb(iobase+FS_FO)) & FS_FO_FSFDR) { |
| 780 | st_fifo->entries[st_fifo->tail].status = status; |
| 781 | |
| 782 | st_fifo->entries[st_fifo->tail].len = inb(iobase+RFLFL); |
| 783 | st_fifo->entries[st_fifo->tail].len |= inb(iobase+RFLFH) << 8; |
| 784 | |
| 785 | st_fifo->tail++; |
| 786 | st_fifo->len++; |
| 787 | } |
| 788 | |
| 789 | while (st_fifo->len) { |
| 790 | /* Get first entry */ |
| 791 | status = st_fifo->entries[st_fifo->head].status; |
| 792 | len = st_fifo->entries[st_fifo->head].len; |
| 793 | st_fifo->head++; |
| 794 | st_fifo->len--; |
| 795 | |
| 796 | /* Check for errors */ |
| 797 | if (status & FS_FO_ERR_MSK) { |
| 798 | if (status & FS_FO_LST_FR) { |
| 799 | /* Add number of lost frames to stats */ |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 800 | self->netdev->stats.rx_errors += len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | } else { |
| 802 | /* Skip frame */ |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 803 | self->netdev->stats.rx_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | |
| 805 | self->rx_buff.data += len; |
| 806 | |
| 807 | if (status & FS_FO_MX_LEX) |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 808 | self->netdev->stats.rx_length_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | |
| 810 | if (status & FS_FO_PHY_ERR) |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 811 | self->netdev->stats.rx_frame_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | |
| 813 | if (status & FS_FO_CRC_ERR) |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 814 | self->netdev->stats.rx_crc_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | } |
| 816 | /* The errors below can be reported in both cases */ |
| 817 | if (status & FS_FO_RX_OV) |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 818 | self->netdev->stats.rx_fifo_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | |
| 820 | if (status & FS_FO_FSF_OV) |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 821 | self->netdev->stats.rx_fifo_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | |
| 823 | } else { |
| 824 | /* Check if we have transferred all data to memory */ |
| 825 | switch_bank(iobase, SET0); |
| 826 | if (inb(iobase+USR) & USR_RDR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | udelay(80); /* Should be enough!? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | } |
| 829 | |
| 830 | skb = dev_alloc_skb(len+1); |
| 831 | if (skb == NULL) { |
| 832 | printk(KERN_INFO |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 833 | "%s(), memory squeeze, dropping frame.\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | /* Restore set register */ |
| 835 | outb(set, iobase+SSR); |
| 836 | |
| 837 | return FALSE; |
| 838 | } |
| 839 | |
| 840 | /* Align to 20 bytes */ |
| 841 | skb_reserve(skb, 1); |
| 842 | |
| 843 | /* Copy frame without CRC */ |
| 844 | if (self->io.speed < 4000000) { |
| 845 | skb_put(skb, len-2); |
Arnaldo Carvalho de Melo | 27d7ff4 | 2007-03-31 11:55:19 -0300 | [diff] [blame] | 846 | skb_copy_to_linear_data(skb, |
| 847 | self->rx_buff.data, |
| 848 | len - 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | } else { |
| 850 | skb_put(skb, len-4); |
Arnaldo Carvalho de Melo | 27d7ff4 | 2007-03-31 11:55:19 -0300 | [diff] [blame] | 851 | skb_copy_to_linear_data(skb, |
| 852 | self->rx_buff.data, |
| 853 | len - 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | /* Move to next frame */ |
| 857 | self->rx_buff.data += len; |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 858 | self->netdev->stats.rx_packets++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | |
| 860 | skb->dev = self->netdev; |
Arnaldo Carvalho de Melo | 459a98e | 2007-03-19 15:30:44 -0700 | [diff] [blame] | 861 | skb_reset_mac_header(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | skb->protocol = htons(ETH_P_IRDA); |
| 863 | netif_rx(skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | } |
| 865 | } |
| 866 | /* Restore set register */ |
| 867 | outb(set, iobase+SSR); |
| 868 | |
| 869 | return TRUE; |
| 870 | } |
| 871 | |
| 872 | /* |
| 873 | * Function pc87108_pio_receive (self) |
| 874 | * |
| 875 | * Receive all data in receiver FIFO |
| 876 | * |
| 877 | */ |
| 878 | static void w83977af_pio_receive(struct w83977af_ir *self) |
| 879 | { |
| 880 | __u8 byte = 0x00; |
| 881 | int iobase; |
| 882 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 883 | IRDA_DEBUG(4, "%s()\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | |
| 885 | IRDA_ASSERT(self != NULL, return;); |
| 886 | |
| 887 | iobase = self->io.fir_base; |
| 888 | |
| 889 | /* Receive all characters in Rx FIFO */ |
| 890 | do { |
| 891 | byte = inb(iobase+RBR); |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 892 | async_unwrap_char(self->netdev, &self->netdev->stats, &self->rx_buff, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | byte); |
| 894 | } while (inb(iobase+USR) & USR_RDR); /* Data available */ |
| 895 | } |
| 896 | |
| 897 | /* |
| 898 | * Function w83977af_sir_interrupt (self, eir) |
| 899 | * |
| 900 | * Handle SIR interrupt |
| 901 | * |
| 902 | */ |
| 903 | static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr) |
| 904 | { |
| 905 | int actual; |
| 906 | __u8 new_icr = 0; |
| 907 | __u8 set; |
| 908 | int iobase; |
| 909 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 910 | IRDA_DEBUG(4, "%s(), isr=%#x\n", __func__ , isr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | |
| 912 | iobase = self->io.fir_base; |
| 913 | /* Transmit FIFO low on data */ |
| 914 | if (isr & ISR_TXTH_I) { |
| 915 | /* Write data left in transmit buffer */ |
| 916 | actual = w83977af_pio_write(self->io.fir_base, |
| 917 | self->tx_buff.data, |
| 918 | self->tx_buff.len, |
| 919 | self->io.fifo_size); |
| 920 | |
| 921 | self->tx_buff.data += actual; |
| 922 | self->tx_buff.len -= actual; |
| 923 | |
| 924 | self->io.direction = IO_XMIT; |
| 925 | |
| 926 | /* Check if finished */ |
| 927 | if (self->tx_buff.len > 0) { |
| 928 | new_icr |= ICR_ETXTHI; |
| 929 | } else { |
| 930 | set = inb(iobase+SSR); |
| 931 | switch_bank(iobase, SET0); |
| 932 | outb(AUDR_SFEND, iobase+AUDR); |
| 933 | outb(set, iobase+SSR); |
| 934 | |
Stephen Hemminger | af04908 | 2009-01-06 10:40:43 -0800 | [diff] [blame] | 935 | self->netdev->stats.tx_packets++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | |
| 937 | /* Feed me more packets */ |
| 938 | netif_wake_queue(self->netdev); |
| 939 | new_icr |= ICR_ETBREI; |
| 940 | } |
| 941 | } |
| 942 | /* Check if transmission has completed */ |
| 943 | if (isr & ISR_TXEMP_I) { |
| 944 | /* Check if we need to change the speed? */ |
| 945 | if (self->new_speed) { |
| 946 | IRDA_DEBUG(2, |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 947 | "%s(), Changing speed!\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 948 | w83977af_change_speed(self, self->new_speed); |
| 949 | self->new_speed = 0; |
| 950 | } |
| 951 | |
| 952 | /* Turn around and get ready to receive some data */ |
| 953 | self->io.direction = IO_RECV; |
| 954 | new_icr |= ICR_ERBRI; |
| 955 | } |
| 956 | |
| 957 | /* Rx FIFO threshold or timeout */ |
| 958 | if (isr & ISR_RXTH_I) { |
| 959 | w83977af_pio_receive(self); |
| 960 | |
| 961 | /* Keep receiving */ |
| 962 | new_icr |= ICR_ERBRI; |
| 963 | } |
| 964 | return new_icr; |
| 965 | } |
| 966 | |
| 967 | /* |
| 968 | * Function pc87108_fir_interrupt (self, eir) |
| 969 | * |
| 970 | * Handle MIR/FIR interrupt |
| 971 | * |
| 972 | */ |
| 973 | static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr) |
| 974 | { |
| 975 | __u8 new_icr = 0; |
| 976 | __u8 set; |
| 977 | int iobase; |
| 978 | |
| 979 | iobase = self->io.fir_base; |
| 980 | set = inb(iobase+SSR); |
| 981 | |
| 982 | /* End of frame detected in FIFO */ |
| 983 | if (isr & (ISR_FEND_I|ISR_FSF_I)) { |
| 984 | if (w83977af_dma_receive_complete(self)) { |
| 985 | |
| 986 | /* Wait for next status FIFO interrupt */ |
| 987 | new_icr |= ICR_EFSFI; |
| 988 | } else { |
| 989 | /* DMA not finished yet */ |
| 990 | |
| 991 | /* Set timer value, resolution 1 ms */ |
| 992 | switch_bank(iobase, SET4); |
| 993 | outb(0x01, iobase+TMRL); /* 1 ms */ |
| 994 | outb(0x00, iobase+TMRH); |
| 995 | |
| 996 | /* Start timer */ |
| 997 | outb(IR_MSL_EN_TMR, iobase+IR_MSL); |
| 998 | |
| 999 | new_icr |= ICR_ETMRI; |
| 1000 | } |
| 1001 | } |
| 1002 | /* Timer finished */ |
| 1003 | if (isr & ISR_TMR_I) { |
| 1004 | /* Disable timer */ |
| 1005 | switch_bank(iobase, SET4); |
| 1006 | outb(0, iobase+IR_MSL); |
| 1007 | |
| 1008 | /* Clear timer event */ |
| 1009 | /* switch_bank(iobase, SET0); */ |
| 1010 | /* outb(ASCR_CTE, iobase+ASCR); */ |
| 1011 | |
| 1012 | /* Check if this is a TX timer interrupt */ |
| 1013 | if (self->io.direction == IO_XMIT) { |
| 1014 | w83977af_dma_write(self, iobase); |
| 1015 | |
| 1016 | new_icr |= ICR_EDMAI; |
| 1017 | } else { |
| 1018 | /* Check if DMA has now finished */ |
| 1019 | w83977af_dma_receive_complete(self); |
| 1020 | |
| 1021 | new_icr |= ICR_EFSFI; |
| 1022 | } |
| 1023 | } |
| 1024 | /* Finished with DMA */ |
| 1025 | if (isr & ISR_DMA_I) { |
| 1026 | w83977af_dma_xmit_complete(self); |
| 1027 | |
| 1028 | /* Check if there are more frames to be transmitted */ |
| 1029 | /* if (irda_device_txqueue_empty(self)) { */ |
| 1030 | |
| 1031 | /* Prepare for receive |
| 1032 | * |
| 1033 | * ** Netwinder Tx DMA likes that we do this anyway ** |
| 1034 | */ |
| 1035 | w83977af_dma_receive(self); |
| 1036 | new_icr = ICR_EFSFI; |
| 1037 | /* } */ |
| 1038 | } |
| 1039 | |
| 1040 | /* Restore set */ |
| 1041 | outb(set, iobase+SSR); |
| 1042 | |
| 1043 | return new_icr; |
| 1044 | } |
| 1045 | |
| 1046 | /* |
| 1047 | * Function w83977af_interrupt (irq, dev_id, regs) |
| 1048 | * |
| 1049 | * An interrupt from the chip has arrived. Time to do some work |
| 1050 | * |
| 1051 | */ |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 1052 | static irqreturn_t w83977af_interrupt(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | { |
Jeff Garzik | c31f28e | 2006-10-06 14:56:04 -0400 | [diff] [blame] | 1054 | struct net_device *dev = dev_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | struct w83977af_ir *self; |
| 1056 | __u8 set, icr, isr; |
| 1057 | int iobase; |
| 1058 | |
Wang Chen | 4cf1653 | 2008-11-12 23:38:14 -0800 | [diff] [blame] | 1059 | self = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | |
| 1061 | iobase = self->io.fir_base; |
| 1062 | |
| 1063 | /* Save current bank */ |
| 1064 | set = inb(iobase+SSR); |
| 1065 | switch_bank(iobase, SET0); |
| 1066 | |
| 1067 | icr = inb(iobase+ICR); |
| 1068 | isr = inb(iobase+ISR) & icr; /* Mask out the interesting ones */ |
| 1069 | |
| 1070 | outb(0, iobase+ICR); /* Disable interrupts */ |
| 1071 | |
| 1072 | if (isr) { |
| 1073 | /* Dispatch interrupt handler for the current speed */ |
| 1074 | if (self->io.speed > PIO_MAX_SPEED ) |
| 1075 | icr = w83977af_fir_interrupt(self, isr); |
| 1076 | else |
| 1077 | icr = w83977af_sir_interrupt(self, isr); |
| 1078 | } |
| 1079 | |
| 1080 | outb(icr, iobase+ICR); /* Restore (new) interrupts */ |
| 1081 | outb(set, iobase+SSR); /* Restore bank register */ |
| 1082 | return IRQ_RETVAL(isr); |
| 1083 | } |
| 1084 | |
| 1085 | /* |
| 1086 | * Function w83977af_is_receiving (self) |
| 1087 | * |
| 1088 | * Return TRUE is we are currently receiving a frame |
| 1089 | * |
| 1090 | */ |
| 1091 | static int w83977af_is_receiving(struct w83977af_ir *self) |
| 1092 | { |
| 1093 | int status = FALSE; |
| 1094 | int iobase; |
| 1095 | __u8 set; |
| 1096 | |
| 1097 | IRDA_ASSERT(self != NULL, return FALSE;); |
| 1098 | |
| 1099 | if (self->io.speed > 115200) { |
| 1100 | iobase = self->io.fir_base; |
| 1101 | |
| 1102 | /* Check if rx FIFO is not empty */ |
| 1103 | set = inb(iobase+SSR); |
| 1104 | switch_bank(iobase, SET2); |
| 1105 | if ((inb(iobase+RXFDTH) & 0x3f) != 0) { |
| 1106 | /* We are receiving something */ |
| 1107 | status = TRUE; |
| 1108 | } |
| 1109 | outb(set, iobase+SSR); |
| 1110 | } else |
| 1111 | status = (self->rx_buff.state != OUTSIDE_FRAME); |
| 1112 | |
| 1113 | return status; |
| 1114 | } |
| 1115 | |
| 1116 | /* |
| 1117 | * Function w83977af_net_open (dev) |
| 1118 | * |
| 1119 | * Start the device |
| 1120 | * |
| 1121 | */ |
| 1122 | static int w83977af_net_open(struct net_device *dev) |
| 1123 | { |
| 1124 | struct w83977af_ir *self; |
| 1125 | int iobase; |
| 1126 | char hwname[32]; |
| 1127 | __u8 set; |
| 1128 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 1129 | IRDA_DEBUG(0, "%s()\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | |
| 1131 | IRDA_ASSERT(dev != NULL, return -1;); |
Wang Chen | 4cf1653 | 2008-11-12 23:38:14 -0800 | [diff] [blame] | 1132 | self = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | |
| 1134 | IRDA_ASSERT(self != NULL, return 0;); |
| 1135 | |
| 1136 | iobase = self->io.fir_base; |
| 1137 | |
| 1138 | if (request_irq(self->io.irq, w83977af_interrupt, 0, dev->name, |
| 1139 | (void *) dev)) { |
| 1140 | return -EAGAIN; |
| 1141 | } |
| 1142 | /* |
| 1143 | * Always allocate the DMA channel after the IRQ, |
| 1144 | * and clean up on failure. |
| 1145 | */ |
| 1146 | if (request_dma(self->io.dma, dev->name)) { |
Julia Lawall | a997cbb | 2012-03-11 11:49:02 +0000 | [diff] [blame] | 1147 | free_irq(self->io.irq, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | return -EAGAIN; |
| 1149 | } |
| 1150 | |
| 1151 | /* Save current set */ |
| 1152 | set = inb(iobase+SSR); |
| 1153 | |
| 1154 | /* Enable some interrupts so we can receive frames again */ |
| 1155 | switch_bank(iobase, SET0); |
| 1156 | if (self->io.speed > 115200) { |
| 1157 | outb(ICR_EFSFI, iobase+ICR); |
| 1158 | w83977af_dma_receive(self); |
| 1159 | } else |
| 1160 | outb(ICR_ERBRI, iobase+ICR); |
| 1161 | |
| 1162 | /* Restore bank register */ |
| 1163 | outb(set, iobase+SSR); |
| 1164 | |
| 1165 | /* Ready to play! */ |
| 1166 | netif_start_queue(dev); |
| 1167 | |
| 1168 | /* Give self a hardware name */ |
| 1169 | sprintf(hwname, "w83977af @ 0x%03x", self->io.fir_base); |
| 1170 | |
| 1171 | /* |
| 1172 | * Open new IrLAP layer instance, now that everything should be |
| 1173 | * initialized properly |
| 1174 | */ |
| 1175 | self->irlap = irlap_open(dev, &self->qos, hwname); |
| 1176 | |
| 1177 | return 0; |
| 1178 | } |
| 1179 | |
| 1180 | /* |
| 1181 | * Function w83977af_net_close (dev) |
| 1182 | * |
| 1183 | * Stop the device |
| 1184 | * |
| 1185 | */ |
| 1186 | static int w83977af_net_close(struct net_device *dev) |
| 1187 | { |
| 1188 | struct w83977af_ir *self; |
| 1189 | int iobase; |
| 1190 | __u8 set; |
| 1191 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 1192 | IRDA_DEBUG(0, "%s()\n", __func__ ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1193 | |
| 1194 | IRDA_ASSERT(dev != NULL, return -1;); |
| 1195 | |
Wang Chen | 4cf1653 | 2008-11-12 23:38:14 -0800 | [diff] [blame] | 1196 | self = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | |
| 1198 | IRDA_ASSERT(self != NULL, return 0;); |
| 1199 | |
| 1200 | iobase = self->io.fir_base; |
| 1201 | |
| 1202 | /* Stop device */ |
| 1203 | netif_stop_queue(dev); |
| 1204 | |
| 1205 | /* Stop and remove instance of IrLAP */ |
| 1206 | if (self->irlap) |
| 1207 | irlap_close(self->irlap); |
| 1208 | self->irlap = NULL; |
| 1209 | |
| 1210 | disable_dma(self->io.dma); |
| 1211 | |
| 1212 | /* Save current set */ |
| 1213 | set = inb(iobase+SSR); |
| 1214 | |
| 1215 | /* Disable interrupts */ |
| 1216 | switch_bank(iobase, SET0); |
| 1217 | outb(0, iobase+ICR); |
| 1218 | |
| 1219 | free_irq(self->io.irq, dev); |
| 1220 | free_dma(self->io.dma); |
| 1221 | |
| 1222 | /* Restore bank register */ |
| 1223 | outb(set, iobase+SSR); |
| 1224 | |
| 1225 | return 0; |
| 1226 | } |
| 1227 | |
| 1228 | /* |
| 1229 | * Function w83977af_net_ioctl (dev, rq, cmd) |
| 1230 | * |
| 1231 | * Process IOCTL commands for this device |
| 1232 | * |
| 1233 | */ |
| 1234 | static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
| 1235 | { |
| 1236 | struct if_irda_req *irq = (struct if_irda_req *) rq; |
| 1237 | struct w83977af_ir *self; |
| 1238 | unsigned long flags; |
| 1239 | int ret = 0; |
| 1240 | |
| 1241 | IRDA_ASSERT(dev != NULL, return -1;); |
| 1242 | |
Wang Chen | 4cf1653 | 2008-11-12 23:38:14 -0800 | [diff] [blame] | 1243 | self = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1244 | |
| 1245 | IRDA_ASSERT(self != NULL, return -1;); |
| 1246 | |
Harvey Harrison | a97a6f1 | 2008-07-30 17:20:18 -0700 | [diff] [blame] | 1247 | IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__ , dev->name, cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | |
| 1249 | spin_lock_irqsave(&self->lock, flags); |
| 1250 | |
| 1251 | switch (cmd) { |
| 1252 | case SIOCSBANDWIDTH: /* Set bandwidth */ |
| 1253 | if (!capable(CAP_NET_ADMIN)) { |
| 1254 | ret = -EPERM; |
| 1255 | goto out; |
| 1256 | } |
| 1257 | w83977af_change_speed(self, irq->ifr_baudrate); |
| 1258 | break; |
| 1259 | case SIOCSMEDIABUSY: /* Set media busy */ |
| 1260 | if (!capable(CAP_NET_ADMIN)) { |
| 1261 | ret = -EPERM; |
| 1262 | goto out; |
| 1263 | } |
| 1264 | irda_device_set_media_busy(self->netdev, TRUE); |
| 1265 | break; |
| 1266 | case SIOCGRECEIVING: /* Check if we are receiving right now */ |
| 1267 | irq->ifr_receiving = w83977af_is_receiving(self); |
| 1268 | break; |
| 1269 | default: |
| 1270 | ret = -EOPNOTSUPP; |
| 1271 | } |
| 1272 | out: |
| 1273 | spin_unlock_irqrestore(&self->lock, flags); |
| 1274 | return ret; |
| 1275 | } |
| 1276 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1277 | MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>"); |
| 1278 | MODULE_DESCRIPTION("Winbond W83977AF IrDA Device Driver"); |
| 1279 | MODULE_LICENSE("GPL"); |
| 1280 | |
| 1281 | |
| 1282 | module_param(qos_mtt_bits, int, 0); |
| 1283 | MODULE_PARM_DESC(qos_mtt_bits, "Mimimum Turn Time"); |
| 1284 | module_param_array(io, int, NULL, 0); |
| 1285 | MODULE_PARM_DESC(io, "Base I/O addresses"); |
| 1286 | module_param_array(irq, int, NULL, 0); |
| 1287 | MODULE_PARM_DESC(irq, "IRQ lines"); |
| 1288 | |
| 1289 | /* |
| 1290 | * Function init_module (void) |
| 1291 | * |
| 1292 | * |
| 1293 | * |
| 1294 | */ |
| 1295 | module_init(w83977af_init); |
| 1296 | |
| 1297 | /* |
| 1298 | * Function cleanup_module (void) |
| 1299 | * |
| 1300 | * |
| 1301 | * |
| 1302 | */ |
| 1303 | module_exit(w83977af_cleanup); |