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