1 /*********************************************************************
2 * $Id: smsc-ircc2.c,v 1.19.2.5 2002/10/27 11:34:26 dip Exp $
4 * Description: Driver for the SMC Infrared Communications Controller
5 * Status: Experimental.
6 * Author: Daniele Peri (peri@csai.unipa.it)
11 * Copyright (c) 2002 Daniele Peri
12 * All Rights Reserved.
13 * Copyright (c) 2002 Jean Tourrilhes
16 * Based on smc-ircc.c:
18 * Copyright (c) 2001 Stefani Seibold
19 * Copyright (c) 1999-2001 Dag Brattli
20 * Copyright (c) 1998-1999 Thomas Davis,
24 * Copyright (c) 1997, 1998, 1999-2000 Dag Brattli, All Rights Reserved.
27 * This program is free software; you can redistribute it and/or
28 * modify it under the terms of the GNU General Public License as
29 * published by the Free Software Foundation; either version 2 of
30 * the License, or (at your option) any later version.
32 * This program is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 * GNU General Public License for more details.
37 * You should have received a copy of the GNU General Public License
38 * along with this program; if not, write to the Free Software
39 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
42 ********************************************************************/
44 #include <linux/module.h>
45 #include <linux/kernel.h>
46 #include <linux/types.h>
47 #include <linux/skbuff.h>
48 #include <linux/netdevice.h>
49 #include <linux/ioport.h>
50 #include <linux/delay.h>
51 #include <linux/slab.h>
52 #include <linux/init.h>
53 #include <linux/rtnetlink.h>
54 #include <linux/serial_reg.h>
55 #include <linux/dma-mapping.h>
59 #include <asm/byteorder.h>
61 #include <linux/spinlock.h>
64 #include <net/irda/wrapper.h>
65 #include <net/irda/irda.h>
66 #include <net/irda/irda_device.h>
68 #include "smsc-ircc2.h"
73 struct smsc_transceiver {
75 void (*set_for_speed)(int fir_base, u32 speed);
76 int (*probe)(int fir_base);
78 typedef struct smsc_transceiver smsc_transceiver_t;
87 typedef struct smc_chip smc_chip_t;
99 typedef struct smsc_chip smsc_chip_t;
101 struct smsc_chip_address {
102 unsigned int cfg_base;
105 typedef struct smsc_chip_address smsc_chip_address_t;
107 /* Private data for each instance */
108 struct smsc_ircc_cb {
109 struct net_device *netdev; /* Yes! we are some kind of netdevice */
110 struct net_device_stats stats;
111 struct irlap_cb *irlap; /* The link layer we are binded to */
113 chipio_t io; /* IrDA controller information */
114 iobuff_t tx_buff; /* Transmit buffer */
115 iobuff_t rx_buff; /* Receive buffer */
116 dma_addr_t tx_buff_dma;
117 dma_addr_t rx_buff_dma;
119 struct qos_info qos; /* QoS capabilities for this device */
121 spinlock_t lock; /* For serializing operations */
124 __u32 flags; /* Interface flags */
126 int tx_buff_offsets[10]; /* Offsets between frames in tx_buff */
127 int tx_len; /* Number of frames in tx_buff */
130 struct pm_dev *pmdev;
135 static const char *driver_name = "smsc-ircc2";
136 #define DIM(x) (sizeof(x)/(sizeof(*(x))))
137 #define SMSC_IRCC2_C_IRDA_FALLBACK_SPEED 9600
138 #define SMSC_IRCC2_C_DEFAULT_TRANSCEIVER 1
139 #define SMSC_IRCC2_C_NET_TIMEOUT 0
140 #define SMSC_IRCC2_C_SIR_STOP 0
144 static int smsc_ircc_open(unsigned int firbase, unsigned int sirbase, u8 dma, u8 irq);
145 static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base);
146 static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq);
147 static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self);
148 static void smsc_ircc_init_chip(struct smsc_ircc_cb *self);
149 static int __exit smsc_ircc_close(struct smsc_ircc_cb *self);
150 static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self, int iobase);
151 static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self, int iobase);
152 static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self);
153 static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev);
154 static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev);
155 static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int iobase, int bofs);
156 static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self, int iobase);
157 static void smsc_ircc_change_speed(void *priv, u32 speed);
158 static void smsc_ircc_set_sir_speed(void *priv, u32 speed);
159 static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
160 static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev);
161 static void smsc_ircc_sir_start(struct smsc_ircc_cb *self);
162 #if SMSC_IRCC2_C_SIR_STOP
163 static void smsc_ircc_sir_stop(struct smsc_ircc_cb *self);
165 static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self);
166 static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len);
167 static int smsc_ircc_net_open(struct net_device *dev);
168 static int smsc_ircc_net_close(struct net_device *dev);
169 static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
170 #if SMSC_IRCC2_C_NET_TIMEOUT
171 static void smsc_ircc_timeout(struct net_device *dev);
173 static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev);
174 static int smsc_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data);
175 static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self);
176 static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self);
177 static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed);
178 static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self);
181 static int __init smsc_ircc_look_for_chips(void);
182 static const smsc_chip_t * __init smsc_ircc_probe(unsigned short cfg_base,u8 reg,const smsc_chip_t *chip,char *type);
183 static int __init smsc_superio_flat(const smsc_chip_t *chips, unsigned short cfg_base, char *type);
184 static int __init smsc_superio_paged(const smsc_chip_t *chips, unsigned short cfg_base, char *type);
185 static int __init smsc_superio_fdc(unsigned short cfg_base);
186 static int __init smsc_superio_lpc(unsigned short cfg_base);
188 /* Transceivers specific functions */
190 static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed);
191 static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base);
192 static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed);
193 static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base);
194 static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed);
195 static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base);
197 /* Power Management */
199 static void smsc_ircc_suspend(struct smsc_ircc_cb *self);
200 static void smsc_ircc_wakeup(struct smsc_ircc_cb *self);
201 static int smsc_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data);
204 /* Transceivers for SMSC-ircc */
206 smsc_transceiver_t smsc_transceivers[]=
208 { "Toshiba Satellite 1800 (GP data pin select)", smsc_ircc_set_transceiver_toshiba_sat1800, smsc_ircc_probe_transceiver_toshiba_sat1800},
209 { "Fast pin select", smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select, smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select},
210 { "ATC IRMode", smsc_ircc_set_transceiver_smsc_ircc_atc, smsc_ircc_probe_transceiver_smsc_ircc_atc},
213 #define SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS (DIM(smsc_transceivers)-1)
215 /* SMC SuperIO chipsets definitions */
217 #define KEY55_1 0 /* SuperIO Configuration mode with Key <0x55> */
218 #define KEY55_2 1 /* SuperIO Configuration mode with Key <0x55,0x55> */
219 #define NoIRDA 2 /* SuperIO Chip has no IRDA Port */
220 #define SIR 0 /* SuperIO Chip has only slow IRDA */
221 #define FIR 4 /* SuperIO Chip has fast IRDA */
222 #define SERx4 8 /* SuperIO Chip supports 115,2 KBaud * 4=460,8 KBaud */
224 static smsc_chip_t __initdata fdc_chips_flat[]=
226 /* Base address 0x3f0 or 0x370 */
227 { "37C44", KEY55_1|NoIRDA, 0x00, 0x00 }, /* This chip cannot be detected */
228 { "37C665GT", KEY55_2|NoIRDA, 0x65, 0x01 },
229 { "37C665GT", KEY55_2|NoIRDA, 0x66, 0x01 },
230 { "37C669", KEY55_2|SIR|SERx4, 0x03, 0x02 },
231 { "37C669", KEY55_2|SIR|SERx4, 0x04, 0x02 }, /* ID? */
232 { "37C78", KEY55_2|NoIRDA, 0x78, 0x00 },
233 { "37N769", KEY55_1|FIR|SERx4, 0x28, 0x00 },
234 { "37N869", KEY55_1|FIR|SERx4, 0x29, 0x00 },
238 static smsc_chip_t __initdata fdc_chips_paged[]=
240 /* Base address 0x3f0 or 0x370 */
241 { "37B72X", KEY55_1|SIR|SERx4, 0x4c, 0x00 },
242 { "37B77X", KEY55_1|SIR|SERx4, 0x43, 0x00 },
243 { "37B78X", KEY55_1|SIR|SERx4, 0x44, 0x00 },
244 { "37B80X", KEY55_1|SIR|SERx4, 0x42, 0x00 },
245 { "37C67X", KEY55_1|FIR|SERx4, 0x40, 0x00 },
246 { "37C93X", KEY55_2|SIR|SERx4, 0x02, 0x01 },
247 { "37C93XAPM", KEY55_1|SIR|SERx4, 0x30, 0x01 },
248 { "37C93XFR", KEY55_2|FIR|SERx4, 0x03, 0x01 },
249 { "37M707", KEY55_1|SIR|SERx4, 0x42, 0x00 },
250 { "37M81X", KEY55_1|SIR|SERx4, 0x4d, 0x00 },
251 { "37N958FR", KEY55_1|FIR|SERx4, 0x09, 0x04 },
252 { "37N971", KEY55_1|FIR|SERx4, 0x0a, 0x00 },
253 { "37N972", KEY55_1|FIR|SERx4, 0x0b, 0x00 },
257 static smsc_chip_t __initdata lpc_chips_flat[]=
259 /* Base address 0x2E or 0x4E */
260 { "47N227", KEY55_1|FIR|SERx4, 0x5a, 0x00 },
261 { "47N267", KEY55_1|FIR|SERx4, 0x5e, 0x00 },
265 static smsc_chip_t __initdata lpc_chips_paged[]=
267 /* Base address 0x2E or 0x4E */
268 { "47B27X", KEY55_1|SIR|SERx4, 0x51, 0x00 },
269 { "47B37X", KEY55_1|SIR|SERx4, 0x52, 0x00 },
270 { "47M10X", KEY55_1|SIR|SERx4, 0x59, 0x00 },
271 { "47M120", KEY55_1|NoIRDA|SERx4, 0x5c, 0x00 },
272 { "47M13X", KEY55_1|SIR|SERx4, 0x59, 0x00 },
273 { "47M14X", KEY55_1|SIR|SERx4, 0x5f, 0x00 },
274 { "47N252", KEY55_1|FIR|SERx4, 0x0e, 0x00 },
275 { "47S42X", KEY55_1|SIR|SERx4, 0x57, 0x00 },
279 #define SMSCSIO_TYPE_FDC 1
280 #define SMSCSIO_TYPE_LPC 2
281 #define SMSCSIO_TYPE_FLAT 4
282 #define SMSCSIO_TYPE_PAGED 8
284 static smsc_chip_address_t __initdata possible_addresses[]=
286 {0x3f0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED},
287 {0x370, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED},
288 {0xe0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED},
289 {0x2e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED},
290 {0x4e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED},
296 static struct smsc_ircc_cb *dev_self[] = { NULL, NULL};
298 static int ircc_irq=255;
299 static int ircc_dma=255;
300 static int ircc_fir=0;
301 static int ircc_sir=0;
302 static int ircc_cfg=0;
303 static int ircc_transceiver=0;
305 static unsigned short dev_count=0;
307 static inline void register_bank(int iobase, int bank)
309 outb(((inb(iobase+IRCC_MASTER) & 0xf0) | (bank & 0x07)),
314 /*******************************************************************************
320 *******************************************************************************/
323 * Function smsc_ircc_init ()
325 * Initialize chip. Just try to find out how many chips we are dealing with
328 static int __init smsc_ircc_init(void)
332 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
336 if ((ircc_fir>0)&&(ircc_sir>0)) {
337 MESSAGE(" Overriding FIR address 0x%04x\n", ircc_fir);
338 MESSAGE(" Overriding SIR address 0x%04x\n", ircc_sir);
340 if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq) == 0)
346 /* try user provided configuration register base address */
348 MESSAGE(" Overriding configuration address 0x%04x\n", ircc_cfg);
349 if (!smsc_superio_fdc(ircc_cfg))
351 if (!smsc_superio_lpc(ircc_cfg))
355 if(smsc_ircc_look_for_chips()>0) ret = 0;
361 * Function smsc_ircc_open (firbase, sirbase, dma, irq)
363 * Try to open driver instance
366 static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
368 struct smsc_ircc_cb *self;
369 struct net_device *dev;
372 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
374 err = smsc_ircc_present(fir_base, sir_base);
379 if (dev_count > DIM(dev_self)) {
380 WARNING("%s(), too many devices!\n", __FUNCTION__);
385 * Allocate new instance of the driver
387 dev = alloc_irdadev(sizeof(struct smsc_ircc_cb));
389 WARNING("%s() can't allocate net device\n", __FUNCTION__);
393 SET_MODULE_OWNER(dev);
395 dev->hard_start_xmit = smsc_ircc_hard_xmit_sir;
396 #if SMSC_IRCC2_C_NET_TIMEOUT
397 dev->tx_timeout = smsc_ircc_timeout;
398 dev->watchdog_timeo = HZ*2; /* Allow enough time for speed change */
400 dev->open = smsc_ircc_net_open;
401 dev->stop = smsc_ircc_net_close;
402 dev->do_ioctl = smsc_ircc_net_ioctl;
403 dev->get_stats = smsc_ircc_net_get_stats;
408 /* Make ifconfig display some details */
409 dev->base_addr = self->io.fir_base = fir_base;
410 dev->irq = self->io.irq = irq;
412 /* Need to store self somewhere */
413 dev_self[dev_count++] = self;
414 spin_lock_init(&self->lock);
416 self->rx_buff.truesize = SMSC_IRCC2_RX_BUFF_TRUESIZE;
417 self->tx_buff.truesize = SMSC_IRCC2_TX_BUFF_TRUESIZE;
420 dma_alloc_coherent(NULL, self->rx_buff.truesize,
421 &self->rx_buff_dma, GFP_KERNEL);
422 if (self->rx_buff.head == NULL) {
423 ERROR("%s, Can't allocate memory for receive buffer!\n",
429 dma_alloc_coherent(NULL, self->tx_buff.truesize,
430 &self->tx_buff_dma, GFP_KERNEL);
431 if (self->tx_buff.head == NULL) {
432 ERROR("%s, Can't allocate memory for transmit buffer!\n",
437 memset(self->rx_buff.head, 0, self->rx_buff.truesize);
438 memset(self->tx_buff.head, 0, self->tx_buff.truesize);
440 self->rx_buff.in_frame = FALSE;
441 self->rx_buff.state = OUTSIDE_FRAME;
442 self->tx_buff.data = self->tx_buff.head;
443 self->rx_buff.data = self->rx_buff.head;
445 smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq);
447 smsc_ircc_setup_qos(self);
449 smsc_ircc_init_chip(self);
451 if(ircc_transceiver > 0 &&
452 ircc_transceiver < SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS)
453 self->transceiver = ircc_transceiver;
455 smsc_ircc_probe_transceiver(self);
457 err = register_netdev(self->netdev);
459 ERROR("%s, Network device registration failed!\n",
464 self->pmdev = pm_register(PM_SYS_DEV, PM_SYS_IRDA, smsc_ircc_pmproc);
466 self->pmdev->data = self;
468 MESSAGE("IrDA: Registered device %s\n", dev->name);
472 dma_free_coherent(NULL, self->tx_buff.truesize,
473 self->tx_buff.head, self->tx_buff_dma);
475 dma_free_coherent(NULL, self->rx_buff.truesize,
476 self->rx_buff.head, self->rx_buff_dma);
478 free_netdev(self->netdev);
479 dev_self[--dev_count] = NULL;
481 release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
482 release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
488 * Function smsc_ircc_present(fir_base, sir_base)
490 * Check the smsc-ircc chip presence
493 static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base)
495 unsigned char low, high, chip, config, dma, irq, version;
497 if (!request_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT,
499 WARNING("%s: can't get fir_base of 0x%03x\n",
500 __FUNCTION__, fir_base);
504 if (!request_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT,
506 WARNING("%s: can't get sir_base of 0x%03x\n",
507 __FUNCTION__, sir_base);
511 register_bank(fir_base, 3);
513 high = inb(fir_base+IRCC_ID_HIGH);
514 low = inb(fir_base+IRCC_ID_LOW);
515 chip = inb(fir_base+IRCC_CHIP_ID);
516 version = inb(fir_base+IRCC_VERSION);
517 config = inb(fir_base+IRCC_INTERFACE);
518 dma = config & IRCC_INTERFACE_DMA_MASK;
519 irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4;
521 if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) {
522 WARNING("%s(), addr 0x%04x - no device found!\n",
523 __FUNCTION__, fir_base);
526 MESSAGE("SMsC IrDA Controller found\n IrCC version %d.%d, "
527 "firport 0x%03x, sirport 0x%03x dma=%d, irq=%d\n",
528 chip & 0x0f, version, fir_base, sir_base, dma, irq);
532 release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
534 release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
540 * Function smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq)
545 static void smsc_ircc_setup_io(struct smsc_ircc_cb *self,
546 unsigned int fir_base, unsigned int sir_base,
549 unsigned char config, chip_dma, chip_irq;
551 register_bank(fir_base, 3);
552 config = inb(fir_base+IRCC_INTERFACE);
553 chip_dma = config & IRCC_INTERFACE_DMA_MASK;
554 chip_irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4;
556 self->io.fir_base = fir_base;
557 self->io.sir_base = sir_base;
558 self->io.fir_ext = SMSC_IRCC2_FIR_CHIP_IO_EXTENT;
559 self->io.sir_ext = SMSC_IRCC2_SIR_CHIP_IO_EXTENT;
560 self->io.fifo_size = SMSC_IRCC2_FIFO_SIZE;
561 self->io.speed = SMSC_IRCC2_C_IRDA_FALLBACK_SPEED;
565 MESSAGE("%s, Overriding IRQ - chip says %d, using %d\n",
566 driver_name, chip_irq, irq);
570 self->io.irq = chip_irq;
574 MESSAGE("%s, Overriding DMA - chip says %d, using %d\n",
575 driver_name, chip_dma, dma);
579 self->io.dma = chip_dma;
584 * Function smsc_ircc_setup_qos(self)
589 static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self)
591 /* Initialize QoS for this device */
592 irda_init_max_qos_capabilies(&self->qos);
594 self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|
595 IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8);
597 self->qos.min_turn_time.bits = SMSC_IRCC2_MIN_TURN_TIME;
598 self->qos.window_size.bits = SMSC_IRCC2_WINDOW_SIZE;
599 irda_qos_bits_to_value(&self->qos);
603 * Function smsc_ircc_init_chip(self)
608 static void smsc_ircc_init_chip(struct smsc_ircc_cb *self)
610 int iobase, ir_mode, ctrl, fast;
612 ASSERT( self != NULL, return; );
613 iobase = self->io.fir_base;
615 ir_mode = IRCC_CFGA_IRDA_SIR_A;
619 register_bank(iobase, 0);
620 outb(IRCC_MASTER_RESET, iobase+IRCC_MASTER);
621 outb(0x00, iobase+IRCC_MASTER);
623 register_bank(iobase, 1);
624 outb(((inb(iobase+IRCC_SCE_CFGA) & 0x87) | ir_mode),
625 iobase+IRCC_SCE_CFGA);
627 #ifdef smsc_669 /* Uses pin 88/89 for Rx/Tx */
628 outb(((inb(iobase+IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM),
629 iobase+IRCC_SCE_CFGB);
631 outb(((inb(iobase+IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR),
632 iobase+IRCC_SCE_CFGB);
634 (void) inb(iobase+IRCC_FIFO_THRESHOLD);
635 outb(SMSC_IRCC2_FIFO_THRESHOLD, iobase+IRCC_FIFO_THRESHOLD);
637 register_bank(iobase, 4);
638 outb((inb(iobase+IRCC_CONTROL) & 0x30) | ctrl, iobase+IRCC_CONTROL);
640 register_bank(iobase, 0);
641 outb(fast, iobase+IRCC_LCR_A);
643 smsc_ircc_set_sir_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED);
645 /* Power on device */
646 outb(0x00, iobase+IRCC_MASTER);
650 * Function smsc_ircc_net_ioctl (dev, rq, cmd)
652 * Process IOCTL commands for this device
655 static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
657 struct if_irda_req *irq = (struct if_irda_req *) rq;
658 struct smsc_ircc_cb *self;
662 ASSERT(dev != NULL, return -1;);
666 ASSERT(self != NULL, return -1;);
668 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd);
671 case SIOCSBANDWIDTH: /* Set bandwidth */
672 if (!capable(CAP_NET_ADMIN))
675 /* Make sure we are the only one touching
676 * self->io.speed and the hardware - Jean II */
677 spin_lock_irqsave(&self->lock, flags);
678 smsc_ircc_change_speed(self, irq->ifr_baudrate);
679 spin_unlock_irqrestore(&self->lock, flags);
682 case SIOCSMEDIABUSY: /* Set media busy */
683 if (!capable(CAP_NET_ADMIN)) {
688 irda_device_set_media_busy(self->netdev, TRUE);
690 case SIOCGRECEIVING: /* Check if we are receiving right now */
691 irq->ifr_receiving = smsc_ircc_is_receiving(self);
695 if (!capable(CAP_NET_ADMIN)) {
699 smsc_ircc_sir_set_dtr_rts(dev, irq->ifr_dtr, irq->ifr_rts);
709 static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev)
711 struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) dev->priv;
716 #if SMSC_IRCC2_C_NET_TIMEOUT
718 * Function smsc_ircc_timeout (struct net_device *dev)
720 * The networking timeout management.
724 static void smsc_ircc_timeout(struct net_device *dev)
726 struct smsc_ircc_cb *self;
729 self = (struct smsc_ircc_cb *) dev->priv;
731 WARNING("%s: transmit timed out, changing speed to: %d\n", dev->name, self->io.speed);
732 spin_lock_irqsave(&self->lock, flags);
733 smsc_ircc_sir_start(self);
734 smsc_ircc_change_speed(self, self->io.speed);
735 dev->trans_start = jiffies;
736 netif_wake_queue(dev);
737 spin_unlock_irqrestore(&self->lock, flags);
742 * Function smsc_ircc_hard_xmit_sir (struct sk_buff *skb, struct net_device *dev)
744 * Transmits the current frame until FIFO is full, then
745 * waits until the next transmit interrupt, and continues until the
746 * frame is transmitted.
748 int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
750 struct smsc_ircc_cb *self;
755 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
757 ASSERT(dev != NULL, return 0;);
759 self = (struct smsc_ircc_cb *) dev->priv;
760 ASSERT(self != NULL, return 0;);
762 iobase = self->io.sir_base;
764 netif_stop_queue(dev);
766 /* Make sure test of self->io.speed & speed change are atomic */
767 spin_lock_irqsave(&self->lock, flags);
769 /* Check if we need to change the speed */
770 speed = irda_get_next_speed(skb);
771 if ((speed != self->io.speed) && (speed != -1)) {
772 /* Check for empty frame */
775 * We send frames one by one in SIR mode (no
776 * pipelining), so at this point, if we were sending
777 * a previous frame, we just received the interrupt
778 * telling us it is finished (UART_IIR_THRI).
779 * Therefore, waiting for the transmitter to really
780 * finish draining the fifo won't take too long.
781 * And the interrupt handler is not expected to run.
783 smsc_ircc_sir_wait_hw_transmitter_finish(self);
784 smsc_ircc_change_speed(self, speed);
785 spin_unlock_irqrestore(&self->lock, flags);
789 self->new_speed = speed;
794 self->tx_buff.data = self->tx_buff.head;
796 /* Copy skb to tx_buff while wrapping, stuffing and making CRC */
797 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
798 self->tx_buff.truesize);
800 self->stats.tx_bytes += self->tx_buff.len;
802 /* Turn on transmit finished interrupt. Will fire immediately! */
803 outb(UART_IER_THRI, iobase+UART_IER);
805 spin_unlock_irqrestore(&self->lock, flags);
813 * Function smsc_ircc_set_fir_speed (self, baud)
815 * Change the speed of the device
818 static void smsc_ircc_set_fir_speed(struct smsc_ircc_cb *self, u32 speed)
820 int fir_base, ir_mode, ctrl, fast;
822 ASSERT(self != NULL, return;);
823 fir_base = self->io.fir_base;
825 self->io.speed = speed;
830 ir_mode = IRCC_CFGA_IRDA_HDLC;
833 IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __FUNCTION__);
836 ir_mode = IRCC_CFGA_IRDA_HDLC;
837 ctrl = IRCC_1152 | IRCC_CRC;
838 fast = IRCC_LCR_A_FAST | IRCC_LCR_A_GP_DATA;
839 IRDA_DEBUG(0, "%s(), handling baud of 1152000\n",
843 ir_mode = IRCC_CFGA_IRDA_4PPM;
845 fast = IRCC_LCR_A_FAST;
846 IRDA_DEBUG(0, "%s(), handling baud of 4000000\n",
852 /* This causes an interrupt */
853 register_bank(fir_base, 0);
854 outb((inb(fir_base+IRCC_LCR_A) & 0xbf) | fast, fir_base+IRCC_LCR_A);
857 register_bank(fir_base, 1);
858 outb(((inb(fir_base+IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | ir_mode), fir_base+IRCC_SCE_CFGA);
860 register_bank(fir_base, 4);
861 outb((inb(fir_base+IRCC_CONTROL) & 0x30) | ctrl, fir_base+IRCC_CONTROL);
865 * Function smsc_ircc_fir_start(self)
867 * Change the speed of the device
870 static void smsc_ircc_fir_start(struct smsc_ircc_cb *self)
872 struct net_device *dev;
875 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
877 ASSERT(self != NULL, return;);
879 ASSERT(dev != NULL, return;);
881 fir_base = self->io.fir_base;
883 /* Reset everything */
885 /* Install FIR transmit handler */
886 dev->hard_start_xmit = smsc_ircc_hard_xmit_fir;
889 outb(inb(fir_base+IRCC_LCR_A)|IRCC_LCR_A_FIFO_RESET, fir_base+IRCC_LCR_A);
891 /* Enable interrupt */
892 /*outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, fir_base+IRCC_IER);*/
894 register_bank(fir_base, 1);
896 /* Select the TX/RX interface */
897 #ifdef SMSC_669 /* Uses pin 88/89 for Rx/Tx */
898 outb(((inb(fir_base+IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM),
899 fir_base+IRCC_SCE_CFGB);
901 outb(((inb(fir_base+IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR),
902 fir_base+IRCC_SCE_CFGB);
904 (void) inb(fir_base+IRCC_FIFO_THRESHOLD);
906 /* Enable SCE interrupts */
907 outb(0, fir_base+IRCC_MASTER);
908 register_bank(fir_base, 0);
909 outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, fir_base+IRCC_IER);
910 outb(IRCC_MASTER_INT_EN, fir_base+IRCC_MASTER);
914 * Function smsc_ircc_fir_stop(self, baud)
916 * Change the speed of the device
919 static void smsc_ircc_fir_stop(struct smsc_ircc_cb *self)
923 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
925 ASSERT(self != NULL, return;);
927 fir_base = self->io.fir_base;
928 register_bank(fir_base, 0);
929 /*outb(IRCC_MASTER_RESET, fir_base+IRCC_MASTER);*/
930 outb(inb(fir_base+IRCC_LCR_B) & IRCC_LCR_B_SIP_ENABLE, fir_base+IRCC_LCR_B);
935 * Function smsc_ircc_change_speed(self, baud)
937 * Change the speed of the device
939 * This function *must* be called with spinlock held, because it may
940 * be called from the irq handler. - Jean II
942 static void smsc_ircc_change_speed(void *priv, u32 speed)
944 struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) priv;
945 struct net_device *dev;
947 int last_speed_was_sir;
949 IRDA_DEBUG(0, "%s() changing speed to: %d\n", __FUNCTION__, speed);
951 ASSERT(self != NULL, return;);
953 iobase = self->io.fir_base;
955 last_speed_was_sir = self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED;
960 self->io.speed = speed;
961 last_speed_was_sir = 0;
962 smsc_ircc_fir_start(self);
965 if(self->io.speed == 0)
966 smsc_ircc_sir_start(self);
969 if(!last_speed_was_sir) speed = self->io.speed;
972 if(self->io.speed != speed) smsc_ircc_set_transceiver_for_speed(self, speed);
974 self->io.speed = speed;
976 if(speed <= SMSC_IRCC2_MAX_SIR_SPEED) {
977 if(!last_speed_was_sir) {
978 smsc_ircc_fir_stop(self);
979 smsc_ircc_sir_start(self);
981 smsc_ircc_set_sir_speed(self, speed);
984 if(last_speed_was_sir) {
985 #if SMSC_IRCC2_C_SIR_STOP
986 smsc_ircc_sir_stop(self);
988 smsc_ircc_fir_start(self);
990 smsc_ircc_set_fir_speed(self, speed);
993 self->tx_buff.len = 10;
994 self->tx_buff.data = self->tx_buff.head;
996 smsc_ircc_dma_xmit(self, iobase, 4000);
998 /* Be ready for incoming frames */
999 smsc_ircc_dma_receive(self, iobase);
1002 netif_wake_queue(dev);
1006 * Function smsc_ircc_set_sir_speed (self, speed)
1008 * Set speed of IrDA port to specified baudrate
1011 void smsc_ircc_set_sir_speed(void *priv, __u32 speed)
1013 struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) priv;
1015 int fcr; /* FIFO control reg */
1016 int lcr; /* Line control reg */
1019 IRDA_DEBUG(0, "%s(), Setting speed to: %d\n", __FUNCTION__, speed);
1021 ASSERT(self != NULL, return;);
1022 iobase = self->io.sir_base;
1024 /* Update accounting for new speed */
1025 self->io.speed = speed;
1027 /* Turn off interrupts */
1028 outb(0, iobase+UART_IER);
1030 divisor = SMSC_IRCC2_MAX_SIR_SPEED/speed;
1032 fcr = UART_FCR_ENABLE_FIFO;
1035 * Use trigger level 1 to avoid 3 ms. timeout delay at 9600 bps, and
1036 * almost 1,7 ms at 19200 bps. At speeds above that we can just forget
1037 * about this timeout since it will always be fast enough.
1039 if (self->io.speed < 38400)
1040 fcr |= UART_FCR_TRIGGER_1;
1042 fcr |= UART_FCR_TRIGGER_14;
1044 /* IrDA ports use 8N1 */
1045 lcr = UART_LCR_WLEN8;
1047 outb(UART_LCR_DLAB | lcr, iobase+UART_LCR); /* Set DLAB */
1048 outb(divisor & 0xff, iobase+UART_DLL); /* Set speed */
1049 outb(divisor >> 8, iobase+UART_DLM);
1050 outb(lcr, iobase+UART_LCR); /* Set 8N1 */
1051 outb(fcr, iobase+UART_FCR); /* Enable FIFO's */
1053 /* Turn on interrups */
1054 outb(UART_IER_RLSI|UART_IER_RDI|UART_IER_THRI, iobase+UART_IER);
1056 IRDA_DEBUG(2, "%s() speed changed to: %d\n", __FUNCTION__, speed);
1061 * Function smsc_ircc_hard_xmit_fir (skb, dev)
1063 * Transmit the frame!
1066 static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev)
1068 struct smsc_ircc_cb *self;
1069 unsigned long flags;
1074 ASSERT(dev != NULL, return 0;);
1075 self = (struct smsc_ircc_cb *) dev->priv;
1076 ASSERT(self != NULL, return 0;);
1078 iobase = self->io.fir_base;
1080 netif_stop_queue(dev);
1082 /* Make sure test of self->io.speed & speed change are atomic */
1083 spin_lock_irqsave(&self->lock, flags);
1085 /* Check if we need to change the speed after this frame */
1086 speed = irda_get_next_speed(skb);
1087 if ((speed != self->io.speed) && (speed != -1)) {
1088 /* Check for empty frame */
1090 /* Note : you should make sure that speed changes
1091 * are not going to corrupt any outgoing frame.
1092 * Look at nsc-ircc for the gory details - Jean II */
1093 smsc_ircc_change_speed(self, speed);
1094 spin_unlock_irqrestore(&self->lock, flags);
1098 self->new_speed = speed;
1101 memcpy(self->tx_buff.head, skb->data, skb->len);
1103 self->tx_buff.len = skb->len;
1104 self->tx_buff.data = self->tx_buff.head;
1106 mtt = irda_get_mtt(skb);
1111 * Compute how many BOFs (STA or PA's) we need to waste the
1112 * min turn time given the speed of the link.
1114 bofs = mtt * (self->io.speed / 1000) / 8000;
1118 smsc_ircc_dma_xmit(self, iobase, bofs);
1120 /* Transmit frame */
1121 smsc_ircc_dma_xmit(self, iobase, 0);
1123 spin_unlock_irqrestore(&self->lock, flags);
1130 * Function smsc_ircc_dma_xmit (self, iobase)
1132 * Transmit data using DMA
1135 static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int iobase, int bofs)
1139 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1142 register_bank(iobase, 0);
1143 outb(0x00, iobase+IRCC_LCR_B);
1145 register_bank(iobase, 1);
1146 outb(inb(iobase+IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1147 iobase+IRCC_SCE_CFGB);
1149 self->io.direction = IO_XMIT;
1151 /* Set BOF additional count for generating the min turn time */
1152 register_bank(iobase, 4);
1153 outb(bofs & 0xff, iobase+IRCC_BOF_COUNT_LO);
1154 ctrl = inb(iobase+IRCC_CONTROL) & 0xf0;
1155 outb(ctrl | ((bofs >> 8) & 0x0f), iobase+IRCC_BOF_COUNT_HI);
1157 /* Set max Tx frame size */
1158 outb(self->tx_buff.len >> 8, iobase+IRCC_TX_SIZE_HI);
1159 outb(self->tx_buff.len & 0xff, iobase+IRCC_TX_SIZE_LO);
1161 /*outb(UART_MCR_OUT2, self->io.sir_base + UART_MCR);*/
1163 /* Enable burst mode chip Tx DMA */
1164 register_bank(iobase, 1);
1165 outb(inb(iobase+IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE |
1166 IRCC_CFGB_DMA_BURST, iobase+IRCC_SCE_CFGB);
1168 /* Setup DMA controller (must be done after enabling chip DMA) */
1169 irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
1172 /* Enable interrupt */
1174 register_bank(iobase, 0);
1175 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase+IRCC_IER);
1176 outb(IRCC_MASTER_INT_EN, iobase+IRCC_MASTER);
1178 /* Enable transmit */
1179 outb(IRCC_LCR_B_SCE_TRANSMIT | IRCC_LCR_B_SIP_ENABLE, iobase+IRCC_LCR_B);
1183 * Function smsc_ircc_dma_xmit_complete (self)
1185 * The transfer of a frame in finished. This function will only be called
1186 * by the interrupt handler
1189 static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self, int iobase)
1191 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1194 register_bank(iobase, 0);
1195 outb(0x00, iobase+IRCC_LCR_B);
1197 register_bank(self->io.fir_base, 1);
1198 outb(inb(self->io.fir_base+IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1199 self->io.fir_base+IRCC_SCE_CFGB);
1201 /* Check for underrun! */
1202 register_bank(iobase, 0);
1203 if (inb(iobase+IRCC_LSR) & IRCC_LSR_UNDERRUN) {
1204 self->stats.tx_errors++;
1205 self->stats.tx_fifo_errors++;
1207 /* Reset error condition */
1208 register_bank(iobase, 0);
1209 outb(IRCC_MASTER_ERROR_RESET, iobase+IRCC_MASTER);
1210 outb(0x00, iobase+IRCC_MASTER);
1212 self->stats.tx_packets++;
1213 self->stats.tx_bytes += self->tx_buff.len;
1216 /* Check if it's time to change the speed */
1217 if (self->new_speed) {
1218 smsc_ircc_change_speed(self, self->new_speed);
1219 self->new_speed = 0;
1222 netif_wake_queue(self->netdev);
1226 * Function smsc_ircc_dma_receive(self)
1228 * Get ready for receiving a frame. The device will initiate a DMA
1229 * if it starts to receive a frame.
1232 static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self, int iobase)
1235 /* Turn off chip DMA */
1236 register_bank(iobase, 1);
1237 outb(inb(iobase+IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1238 iobase+IRCC_SCE_CFGB);
1242 register_bank(iobase, 0);
1243 outb(0x00, iobase+IRCC_LCR_B);
1245 /* Turn off chip DMA */
1246 register_bank(iobase, 1);
1247 outb(inb(iobase+IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1248 iobase+IRCC_SCE_CFGB);
1250 self->io.direction = IO_RECV;
1251 self->rx_buff.data = self->rx_buff.head;
1253 /* Set max Rx frame size */
1254 register_bank(iobase, 4);
1255 outb((2050 >> 8) & 0x0f, iobase+IRCC_RX_SIZE_HI);
1256 outb(2050 & 0xff, iobase+IRCC_RX_SIZE_LO);
1258 /* Setup DMA controller */
1259 irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
1262 /* Enable burst mode chip Rx DMA */
1263 register_bank(iobase, 1);
1264 outb(inb(iobase+IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE |
1265 IRCC_CFGB_DMA_BURST, iobase+IRCC_SCE_CFGB);
1267 /* Enable interrupt */
1268 register_bank(iobase, 0);
1269 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase+IRCC_IER);
1270 outb(IRCC_MASTER_INT_EN, iobase+IRCC_MASTER);
1273 /* Enable receiver */
1274 register_bank(iobase, 0);
1275 outb(IRCC_LCR_B_SCE_RECEIVE | IRCC_LCR_B_SIP_ENABLE,
1282 * Function smsc_ircc_dma_receive_complete(self, iobase)
1284 * Finished with receiving frames
1287 static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self, int iobase)
1289 struct sk_buff *skb;
1290 int len, msgcnt, lsr;
1292 register_bank(iobase, 0);
1294 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1297 register_bank(iobase, 0);
1298 outb(0x00, iobase+IRCC_LCR_B);
1300 register_bank(iobase, 0);
1301 outb(inb(iobase+IRCC_LSAR) & ~IRCC_LSAR_ADDRESS_MASK, iobase+IRCC_LSAR);
1302 lsr= inb(iobase+IRCC_LSR);
1303 msgcnt = inb(iobase+IRCC_LCR_B) & 0x08;
1305 IRDA_DEBUG(2, "%s: dma count = %d\n", __FUNCTION__,
1306 get_dma_residue(self->io.dma));
1308 len = self->rx_buff.truesize - get_dma_residue(self->io.dma);
1313 if(lsr & (IRCC_LSR_FRAME_ERROR | IRCC_LSR_CRC_ERROR | IRCC_LSR_SIZE_ERROR)) {
1314 self->stats.rx_errors++;
1315 if(lsr & IRCC_LSR_FRAME_ERROR) self->stats.rx_frame_errors++;
1316 if(lsr & IRCC_LSR_CRC_ERROR) self->stats.rx_crc_errors++;
1317 if(lsr & IRCC_LSR_SIZE_ERROR) self->stats.rx_length_errors++;
1318 if(lsr & (IRCC_LSR_UNDERRUN | IRCC_LSR_OVERRUN)) self->stats.rx_length_errors++;
1322 if (self->io.speed < 4000000)
1327 if ((len < 2) || (len > 2050)) {
1328 WARNING("%s(), bogus len=%d\n", __FUNCTION__, len);
1331 IRDA_DEBUG(2, "%s: msgcnt = %d, len=%d\n", __FUNCTION__, msgcnt, len);
1333 skb = dev_alloc_skb(len+1);
1335 WARNING("%s(), memory squeeze, dropping frame.\n",
1339 /* Make sure IP header gets aligned */
1340 skb_reserve(skb, 1);
1342 memcpy(skb_put(skb, len), self->rx_buff.data, len);
1343 self->stats.rx_packets++;
1344 self->stats.rx_bytes += len;
1346 skb->dev = self->netdev;
1347 skb->mac.raw = skb->data;
1348 skb->protocol = htons(ETH_P_IRDA);
1353 * Function smsc_ircc_sir_receive (self)
1355 * Receive one frame from the infrared port
1358 static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self)
1363 ASSERT(self != NULL, return;);
1365 iobase = self->io.sir_base;
1368 * Receive all characters in Rx FIFO, unwrap and unstuff them.
1369 * async_unwrap_char will deliver all found frames
1372 async_unwrap_char(self->netdev, &self->stats, &self->rx_buff,
1373 inb(iobase+UART_RX));
1375 /* Make sure we don't stay here to long */
1376 if (boguscount++ > 32) {
1377 IRDA_DEBUG(2, "%s(), breaking!\n", __FUNCTION__);
1380 } while (inb(iobase+UART_LSR) & UART_LSR_DR);
1385 * Function smsc_ircc_interrupt (irq, dev_id, regs)
1387 * An interrupt from the chip has arrived. Time to do some work
1390 static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1392 struct net_device *dev = (struct net_device *) dev_id;
1393 struct smsc_ircc_cb *self;
1394 int iobase, iir, lcra, lsr;
1395 irqreturn_t ret = IRQ_NONE;
1398 printk(KERN_WARNING "%s: irq %d for unknown device.\n",
1402 self = (struct smsc_ircc_cb *) dev->priv;
1403 ASSERT(self != NULL, return IRQ_NONE;);
1405 /* Serialise the interrupt handler in various CPUs, stop Tx path */
1406 spin_lock(&self->lock);
1408 /* Check if we should use the SIR interrupt handler */
1409 if (self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED) {
1410 ret = smsc_ircc_interrupt_sir(dev);
1411 goto irq_ret_unlock;
1414 iobase = self->io.fir_base;
1416 register_bank(iobase, 0);
1417 iir = inb(iobase+IRCC_IIR);
1419 goto irq_ret_unlock;
1422 /* Disable interrupts */
1423 outb(0, iobase+IRCC_IER);
1424 lcra = inb(iobase+IRCC_LCR_A);
1425 lsr = inb(iobase+IRCC_LSR);
1427 IRDA_DEBUG(2, "%s(), iir = 0x%02x\n", __FUNCTION__, iir);
1429 if (iir & IRCC_IIR_EOM) {
1430 if (self->io.direction == IO_RECV)
1431 smsc_ircc_dma_receive_complete(self, iobase);
1433 smsc_ircc_dma_xmit_complete(self, iobase);
1435 smsc_ircc_dma_receive(self, iobase);
1438 if (iir & IRCC_IIR_ACTIVE_FRAME) {
1439 /*printk(KERN_WARNING "%s(): Active Frame\n", __FUNCTION__);*/
1442 /* Enable interrupts again */
1444 register_bank(iobase, 0);
1445 outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, iobase+IRCC_IER);
1448 spin_unlock(&self->lock);
1454 * Function irport_interrupt_sir (irq, dev_id, regs)
1456 * Interrupt handler for SIR modes
1458 static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev)
1460 struct smsc_ircc_cb *self = dev->priv;
1465 /* Already locked comming here in smsc_ircc_interrupt() */
1466 /*spin_lock(&self->lock);*/
1468 iobase = self->io.sir_base;
1470 iir = inb(iobase+UART_IIR) & UART_IIR_ID;
1474 /* Clear interrupt */
1475 lsr = inb(iobase+UART_LSR);
1477 IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n",
1478 __FUNCTION__, iir, lsr, iobase);
1482 IRDA_DEBUG(2, "%s(), RLSI\n", __FUNCTION__);
1485 /* Receive interrupt */
1486 smsc_ircc_sir_receive(self);
1489 if (lsr & UART_LSR_THRE)
1490 /* Transmitter ready for data */
1491 smsc_ircc_sir_write_wakeup(self);
1494 IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n",
1499 /* Make sure we don't stay here to long */
1500 if (boguscount++ > 100)
1503 iir = inb(iobase + UART_IIR) & UART_IIR_ID;
1505 /*spin_unlock(&self->lock);*/
1512 * Function ircc_is_receiving (self)
1514 * Return TRUE is we are currently receiving a frame
1517 static int ircc_is_receiving(struct smsc_ircc_cb *self)
1522 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1524 ASSERT(self != NULL, return FALSE;);
1526 IRDA_DEBUG(0, "%s: dma count = %d\n", __FUNCTION__,
1527 get_dma_residue(self->io.dma));
1529 status = (self->rx_buff.state != OUTSIDE_FRAME);
1537 * Function smsc_ircc_net_open (dev)
1542 static int smsc_ircc_net_open(struct net_device *dev)
1544 struct smsc_ircc_cb *self;
1547 unsigned long flags;
1549 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1551 ASSERT(dev != NULL, return -1;);
1552 self = (struct smsc_ircc_cb *) dev->priv;
1553 ASSERT(self != NULL, return 0;);
1555 iobase = self->io.fir_base;
1557 if (request_irq(self->io.irq, smsc_ircc_interrupt, 0, dev->name,
1559 IRDA_DEBUG(0, "%s(), unable to allocate irq=%d\n",
1560 __FUNCTION__, self->io.irq);
1564 spin_lock_irqsave(&self->lock, flags);
1565 /*smsc_ircc_sir_start(self);*/
1567 smsc_ircc_change_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED);
1568 spin_unlock_irqrestore(&self->lock, flags);
1570 /* Give self a hardware name */
1571 /* It would be cool to offer the chip revision here - Jean II */
1572 sprintf(hwname, "SMSC @ 0x%03x", self->io.fir_base);
1575 * Open new IrLAP layer instance, now that everything should be
1576 * initialized properly
1578 self->irlap = irlap_open(dev, &self->qos, hwname);
1581 * Always allocate the DMA channel after the IRQ,
1582 * and clean up on failure.
1584 if (request_dma(self->io.dma, dev->name)) {
1585 smsc_ircc_net_close(dev);
1587 WARNING("%s(), unable to allocate DMA=%d\n",
1588 __FUNCTION__, self->io.dma);
1592 netif_start_queue(dev);
1598 * Function smsc_ircc_net_close (dev)
1603 static int smsc_ircc_net_close(struct net_device *dev)
1605 struct smsc_ircc_cb *self;
1608 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1610 ASSERT(dev != NULL, return -1;);
1611 self = (struct smsc_ircc_cb *) dev->priv;
1612 ASSERT(self != NULL, return 0;);
1614 iobase = self->io.fir_base;
1617 netif_stop_queue(dev);
1619 /* Stop and remove instance of IrLAP */
1621 irlap_close(self->irlap);
1624 free_irq(self->io.irq, dev);
1626 disable_dma(self->io.dma);
1628 free_dma(self->io.dma);
1634 static void smsc_ircc_suspend(struct smsc_ircc_cb *self)
1636 MESSAGE("%s, Suspending\n", driver_name);
1638 if (self->io.suspended)
1641 smsc_ircc_net_close(self->netdev);
1643 self->io.suspended = 1;
1646 static void smsc_ircc_wakeup(struct smsc_ircc_cb *self)
1648 if (!self->io.suspended)
1651 /* The code was doing a "cli()" here, but this can't be right.
1652 * If you need protection, do it in net_open with a spinlock
1653 * or give a good reason. - Jean II */
1655 smsc_ircc_net_open(self->netdev);
1657 MESSAGE("%s, Waking up\n", driver_name);
1660 static int smsc_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data)
1662 struct smsc_ircc_cb *self = (struct smsc_ircc_cb*) dev->data;
1666 smsc_ircc_suspend(self);
1669 smsc_ircc_wakeup(self);
1677 * Function smsc_ircc_close (self)
1679 * Close driver instance
1682 static int __exit smsc_ircc_close(struct smsc_ircc_cb *self)
1685 unsigned long flags;
1687 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1689 ASSERT(self != NULL, return -1;);
1691 iobase = self->io.fir_base;
1694 pm_unregister(self->pmdev);
1696 /* Remove netdevice */
1697 unregister_netdev(self->netdev);
1699 /* Make sure the irq handler is not exectuting */
1700 spin_lock_irqsave(&self->lock, flags);
1702 /* Stop interrupts */
1703 register_bank(iobase, 0);
1704 outb(0, iobase+IRCC_IER);
1705 outb(IRCC_MASTER_RESET, iobase+IRCC_MASTER);
1706 outb(0x00, iobase+IRCC_MASTER);
1708 /* Reset to SIR mode */
1709 register_bank(iobase, 1);
1710 outb(IRCC_CFGA_IRDA_SIR_A|IRCC_CFGA_TX_POLARITY, iobase+IRCC_SCE_CFGA);
1711 outb(IRCC_CFGB_IR, iobase+IRCC_SCE_CFGB);
1713 spin_unlock_irqrestore(&self->lock, flags);
1715 /* Release the PORTS that this driver is using */
1716 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__,
1719 release_region(self->io.fir_base, self->io.fir_ext);
1721 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__,
1724 release_region(self->io.sir_base, self->io.sir_ext);
1726 if (self->tx_buff.head)
1727 dma_free_coherent(NULL, self->tx_buff.truesize,
1728 self->tx_buff.head, self->tx_buff_dma);
1730 if (self->rx_buff.head)
1731 dma_free_coherent(NULL, self->rx_buff.truesize,
1732 self->rx_buff.head, self->rx_buff_dma);
1734 free_netdev(self->netdev);
1739 static void __exit smsc_ircc_cleanup(void)
1743 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1745 for (i=0; i < 2; i++) {
1747 smsc_ircc_close(dev_self[i]);
1752 * Start SIR operations
1754 * This function *must* be called with spinlock held, because it may
1755 * be called from the irq handler (via smsc_ircc_change_speed()). - Jean II
1757 void smsc_ircc_sir_start(struct smsc_ircc_cb *self)
1759 struct net_device *dev;
1760 int fir_base, sir_base;
1762 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1764 ASSERT(self != NULL, return;);
1766 ASSERT(dev != NULL, return;);
1767 dev->hard_start_xmit = &smsc_ircc_hard_xmit_sir;
1769 fir_base = self->io.fir_base;
1770 sir_base = self->io.sir_base;
1772 /* Reset everything */
1773 outb(IRCC_MASTER_RESET, fir_base+IRCC_MASTER);
1775 #if SMSC_IRCC2_C_SIR_STOP
1776 /*smsc_ircc_sir_stop(self);*/
1779 register_bank(fir_base, 1);
1780 outb(((inb(fir_base+IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | IRCC_CFGA_IRDA_SIR_A), fir_base+IRCC_SCE_CFGA);
1782 /* Initialize UART */
1783 outb(UART_LCR_WLEN8, sir_base+UART_LCR); /* Reset DLAB */
1784 outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), sir_base+UART_MCR);
1786 /* Turn on interrups */
1787 outb(UART_IER_RLSI | UART_IER_RDI |UART_IER_THRI, sir_base+UART_IER);
1789 IRDA_DEBUG(3, "%s() - exit\n", __FUNCTION__);
1791 outb(0x00, fir_base+IRCC_MASTER);
1794 #if SMSC_IRCC2_C_SIR_STOP
1795 void smsc_ircc_sir_stop(struct smsc_ircc_cb *self)
1799 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1800 iobase = self->io.sir_base;
1803 outb(0, iobase+UART_MCR);
1805 /* Turn off interrupts */
1806 outb(0, iobase+UART_IER);
1811 * Function smsc_sir_write_wakeup (self)
1813 * Called by the SIR interrupt handler when there's room for more data.
1814 * If we have more packets to send, we send them here.
1817 static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self)
1823 ASSERT(self != NULL, return;);
1825 IRDA_DEBUG(4, "%s\n", __FUNCTION__);
1827 iobase = self->io.sir_base;
1829 /* Finished with frame? */
1830 if (self->tx_buff.len > 0) {
1831 /* Write data left in transmit buffer */
1832 actual = smsc_ircc_sir_write(iobase, self->io.fifo_size,
1833 self->tx_buff.data, self->tx_buff.len);
1834 self->tx_buff.data += actual;
1835 self->tx_buff.len -= actual;
1838 /*if (self->tx_buff.len ==0) {*/
1841 * Now serial buffer is almost free & we can start
1842 * transmission of another packet. But first we must check
1843 * if we need to change the speed of the hardware
1845 if (self->new_speed) {
1846 IRDA_DEBUG(5, "%s(), Changing speed to %d.\n",
1847 __FUNCTION__, self->new_speed);
1848 smsc_ircc_sir_wait_hw_transmitter_finish(self);
1849 smsc_ircc_change_speed(self, self->new_speed);
1850 self->new_speed = 0;
1852 /* Tell network layer that we want more frames */
1853 netif_wake_queue(self->netdev);
1855 self->stats.tx_packets++;
1857 if(self->io.speed <= 115200) {
1859 * Reset Rx FIFO to make sure that all reflected transmit data
1860 * is discarded. This is needed for half duplex operation
1862 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR;
1863 if (self->io.speed < 38400)
1864 fcr |= UART_FCR_TRIGGER_1;
1866 fcr |= UART_FCR_TRIGGER_14;
1868 outb(fcr, iobase+UART_FCR);
1870 /* Turn on receive interrupts */
1871 outb(UART_IER_RDI, iobase+UART_IER);
1877 * Function smsc_ircc_sir_write (iobase, fifo_size, buf, len)
1879 * Fill Tx FIFO with transmit data
1882 static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len)
1886 /* Tx FIFO should be empty! */
1887 if (!(inb(iobase+UART_LSR) & UART_LSR_THRE)) {
1888 WARNING("%s(), failed, fifo not empty!\n", __FUNCTION__);
1892 /* Fill FIFO with current frame */
1893 while ((fifo_size-- > 0) && (actual < len)) {
1894 /* Transmit next byte */
1895 outb(buf[actual], iobase+UART_TX);
1902 * Function smsc_ircc_is_receiving (self)
1904 * Returns true is we are currently receiving data
1907 static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self)
1909 return (self->rx_buff.state != OUTSIDE_FRAME);
1914 * Function smsc_ircc_probe_transceiver(self)
1916 * Tries to find the used Transceiver
1919 static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self)
1923 ASSERT(self != NULL, return;);
1925 for(i=0; smsc_transceivers[i].name!=NULL; i++)
1926 if((*smsc_transceivers[i].probe)(self->io.fir_base)) {
1927 MESSAGE(" %s transceiver found\n", smsc_transceivers[i].name);
1928 self->transceiver= i+1;
1931 MESSAGE("No transceiver found. Defaulting to %s\n", smsc_transceivers[SMSC_IRCC2_C_DEFAULT_TRANSCEIVER].name);
1933 self->transceiver= SMSC_IRCC2_C_DEFAULT_TRANSCEIVER;
1938 * Function smsc_ircc_set_transceiver_for_speed(self, speed)
1940 * Set the transceiver according to the speed
1943 static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed)
1947 trx = self->transceiver;
1948 if(trx>0) (*smsc_transceivers[trx-1].set_for_speed)(self->io.fir_base, speed);
1952 * Function smsc_ircc_wait_hw_transmitter_finish ()
1954 * Wait for the real end of HW transmission
1956 * The UART is a strict FIFO, and we get called only when we have finished
1957 * pushing data to the FIFO, so the maximum amount of time we must wait
1958 * is only for the FIFO to drain out.
1960 * We use a simple calibrated loop. We may need to adjust the loop
1961 * delay (udelay) to balance I/O traffic and latency. And we also need to
1962 * adjust the maximum timeout.
1963 * It would probably be better to wait for the proper interrupt,
1964 * but it doesn't seem to be available.
1966 * We can't use jiffies or kernel timers because :
1967 * 1) We are called from the interrupt handler, which disable softirqs,
1968 * so jiffies won't be increased
1969 * 2) Jiffies granularity is usually very coarse (10ms), and we don't
1970 * want to wait that long to detect stuck hardware.
1974 static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self)
1977 int count = SMSC_IRCC2_HW_TRANSMITTER_TIMEOUT_US;
1979 iobase = self->io.sir_base;
1981 /* Calibrated busy loop */
1982 while((count-- > 0) && !(inb(iobase+UART_LSR) & UART_LSR_TEMT))
1986 IRDA_DEBUG(0, "%s(): stuck transmitter\n", __FUNCTION__);
1995 static int __init smsc_ircc_look_for_chips(void)
1997 smsc_chip_address_t *address;
1999 unsigned int cfg_base, found;
2002 address = possible_addresses;
2004 while(address->cfg_base){
2005 cfg_base = address->cfg_base;
2007 /*printk(KERN_WARNING "%s(): probing: 0x%02x for: 0x%02x\n", __FUNCTION__, cfg_base, address->type);*/
2009 if( address->type & SMSCSIO_TYPE_FDC){
2011 if((address->type) & SMSCSIO_TYPE_FLAT) {
2012 if(!smsc_superio_flat(fdc_chips_flat,cfg_base, type)) found++;
2014 if((address->type) & SMSCSIO_TYPE_PAGED) {
2015 if(!smsc_superio_paged(fdc_chips_paged,cfg_base, type)) found++;
2018 if( address->type & SMSCSIO_TYPE_LPC){
2020 if((address->type) & SMSCSIO_TYPE_FLAT) {
2021 if(!smsc_superio_flat(lpc_chips_flat,cfg_base,type)) found++;
2023 if((address->type) & SMSCSIO_TYPE_PAGED) {
2024 if(!smsc_superio_paged(lpc_chips_paged,cfg_base,"LPC")) found++;
2033 * Function smsc_superio_flat (chip, base, type)
2035 * Try to get configuration of a smc SuperIO chip with flat register model
2038 static int __init smsc_superio_flat(const smsc_chip_t *chips, unsigned short cfgbase, char *type)
2040 unsigned short firbase, sirbase;
2044 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2046 if (smsc_ircc_probe(cfgbase, SMSCSIOFLAT_DEVICEID_REG, chips, type)==NULL)
2049 outb(SMSCSIOFLAT_UARTMODE0C_REG, cfgbase);
2050 mode = inb(cfgbase+1);
2052 /*printk(KERN_WARNING "%s(): mode: 0x%02x\n", __FUNCTION__, mode);*/
2054 if(!(mode & SMSCSIOFLAT_UART2MODE_VAL_IRDA))
2055 WARNING("%s(): IrDA not enabled\n", __FUNCTION__);
2057 outb(SMSCSIOFLAT_UART2BASEADDR_REG, cfgbase);
2058 sirbase = inb(cfgbase+1) << 2;
2061 outb(SMSCSIOFLAT_FIRBASEADDR_REG, cfgbase);
2062 firbase = inb(cfgbase+1) << 3;
2065 outb(SMSCSIOFLAT_FIRDMASELECT_REG, cfgbase);
2066 dma = inb(cfgbase+1) & SMSCSIOFLAT_FIRDMASELECT_MASK;
2069 outb(SMSCSIOFLAT_UARTIRQSELECT_REG, cfgbase);
2070 irq = inb(cfgbase+1) & SMSCSIOFLAT_UART2IRQSELECT_MASK;
2072 MESSAGE("%s(): fir: 0x%02x, sir: 0x%02x, dma: %02d, irq: %d, mode: 0x%02x\n", __FUNCTION__, firbase, sirbase, dma, irq, mode);
2075 if (smsc_ircc_open(firbase, sirbase, dma, irq) == 0)
2079 /* Exit configuration */
2080 outb(SMSCSIO_CFGEXITKEY, cfgbase);
2086 * Function smsc_superio_paged (chip, base, type)
2088 * Try to get configuration of a smc SuperIO chip with paged register model
2091 static int __init smsc_superio_paged(const smsc_chip_t *chips, unsigned short cfg_base, char *type)
2093 unsigned short fir_io, sir_io;
2096 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2098 if (smsc_ircc_probe(cfg_base,0x20,chips,type)==NULL)
2101 /* Select logical device (UART2) */
2102 outb(0x07, cfg_base);
2103 outb(0x05, cfg_base + 1);
2106 outb(0x60, cfg_base);
2107 sir_io = inb(cfg_base + 1) << 8;
2108 outb(0x61, cfg_base);
2109 sir_io |= inb(cfg_base + 1);
2112 outb(0x62, cfg_base);
2113 fir_io = inb(cfg_base + 1) << 8;
2114 outb(0x63, cfg_base);
2115 fir_io |= inb(cfg_base + 1);
2116 outb(0x2b, cfg_base); /* ??? */
2119 if (smsc_ircc_open(fir_io, sir_io, ircc_dma, ircc_irq) == 0)
2123 /* Exit configuration */
2124 outb(SMSCSIO_CFGEXITKEY, cfg_base);
2130 static int __init smsc_access(unsigned short cfg_base,unsigned char reg)
2132 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2134 outb(reg, cfg_base);
2136 if (inb(cfg_base)!=reg)
2142 static const smsc_chip_t * __init smsc_ircc_probe(unsigned short cfg_base,u8 reg,const smsc_chip_t *chip,char *type)
2144 u8 devid,xdevid,rev;
2146 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2148 /* Leave configuration */
2150 outb(SMSCSIO_CFGEXITKEY, cfg_base);
2152 if (inb(cfg_base) == SMSCSIO_CFGEXITKEY) /* not a smc superio chip */
2155 outb(reg, cfg_base);
2157 xdevid=inb(cfg_base+1);
2159 /* Enter configuration */
2161 outb(SMSCSIO_CFGACCESSKEY, cfg_base);
2164 if (smsc_access(cfg_base,0x55)) /* send second key and check */
2168 /* probe device ID */
2170 if (smsc_access(cfg_base,reg))
2173 devid=inb(cfg_base+1);
2175 if (devid==0) /* typical value for unused port */
2178 if (devid==0xff) /* typical value for unused port */
2181 /* probe revision ID */
2183 if (smsc_access(cfg_base,reg+1))
2186 rev=inb(cfg_base+1);
2188 if (rev>=128) /* i think this will make no sense */
2191 if (devid==xdevid) /* protection against false positives */
2194 /* Check for expected device ID; are there others? */
2196 while(chip->devid!=devid) {
2200 if (chip->name==NULL)
2204 MESSAGE("found SMC SuperIO Chip (devid=0x%02x rev=%02X base=0x%04x): %s%s\n",devid,rev,cfg_base,type,chip->name);
2207 MESSAGE("Revision higher than expected\n");
2211 if (chip->flags&NoIRDA)
2212 MESSAGE("chipset does not support IRDA\n");
2217 static int __init smsc_superio_fdc(unsigned short cfg_base)
2221 if (!request_region(cfg_base, 2, driver_name)) {
2222 WARNING("%s: can't get cfg_base of 0x%03x\n",
2223 __FUNCTION__, cfg_base);
2225 if (!smsc_superio_flat(fdc_chips_flat,cfg_base,"FDC")
2226 ||!smsc_superio_paged(fdc_chips_paged,cfg_base,"FDC"))
2229 release_region(cfg_base, 2);
2235 static int __init smsc_superio_lpc(unsigned short cfg_base)
2239 if (!request_region(cfg_base, 2, driver_name)) {
2240 WARNING("%s: can't get cfg_base of 0x%03x\n",
2241 __FUNCTION__, cfg_base);
2243 if (!smsc_superio_flat(lpc_chips_flat,cfg_base,"LPC")
2244 ||!smsc_superio_paged(lpc_chips_paged,cfg_base,"LPC"))
2246 release_region(cfg_base, 2);
2251 /************************************************
2253 * Transceivers specific functions
2255 ************************************************/
2259 * Function smsc_ircc_set_transceiver_smsc_ircc_atc(fir_base, speed)
2261 * Program transceiver through smsc-ircc ATC circuitry
2265 static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed)
2267 unsigned long jiffies_now, jiffies_timeout;
2270 jiffies_now= jiffies;
2271 jiffies_timeout= jiffies+SMSC_IRCC2_ATC_PROGRAMMING_TIMEOUT_JIFFIES;
2274 register_bank(fir_base, 4);
2275 outb((inb(fir_base+IRCC_ATC) & IRCC_ATC_MASK) |IRCC_ATC_nPROGREADY|IRCC_ATC_ENABLE, fir_base+IRCC_ATC);
2276 while((val=(inb(fir_base+IRCC_ATC) & IRCC_ATC_nPROGREADY)) && !time_after(jiffies, jiffies_timeout));
2278 WARNING("%s(): ATC: 0x%02x\n", __FUNCTION__,
2279 inb(fir_base+IRCC_ATC));
2283 * Function smsc_ircc_probe_transceiver_smsc_ircc_atc(fir_base)
2285 * Probe transceiver smsc-ircc ATC circuitry
2289 static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base)
2295 * Function smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(self, speed)
2301 static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed)
2313 fast_mode = IRCC_LCR_A_FAST;
2317 register_bank(fir_base, 0);
2318 outb((inb(fir_base+IRCC_LCR_A) & 0xbf) | fast_mode, fir_base+IRCC_LCR_A);
2322 * Function smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(fir_base)
2328 static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base)
2334 * Function smsc_ircc_set_transceiver_toshiba_sat1800(fir_base, speed)
2340 static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed)
2352 fast_mode = /*IRCC_LCR_A_FAST |*/ IRCC_LCR_A_GP_DATA;
2356 /* This causes an interrupt */
2357 register_bank(fir_base, 0);
2358 outb((inb(fir_base+IRCC_LCR_A) & 0xbf) | fast_mode, fir_base+IRCC_LCR_A);
2362 * Function smsc_ircc_probe_transceiver_toshiba_sat1800(fir_base)
2368 static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base)
2374 module_init(smsc_ircc_init);
2375 module_exit(smsc_ircc_cleanup);
2377 MODULE_AUTHOR("Daniele Peri <peri@csai.unipa.it>");
2378 MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver");
2379 MODULE_LICENSE("GPL");
2381 module_param(ircc_dma, int, 0);
2382 MODULE_PARM_DESC(ircc_dma, "DMA channel");
2383 module_param(ircc_irq, int, 0);
2384 MODULE_PARM_DESC(ircc_irq, "IRQ line");
2385 module_param(ircc_fir, int, 0);
2386 MODULE_PARM_DESC(ircc_fir, "FIR Base Address");
2387 module_param(ircc_sir, int, 0);
2388 MODULE_PARM_DESC(ircc_sir, "SIR Base Address");
2389 module_param(ircc_cfg, int, 0);
2390 MODULE_PARM_DESC(ircc_cfg, "Configuration register base address");
2391 module_param(ircc_transceiver, int, 0);
2392 MODULE_PARM_DESC(ircc_transceiver, "Transceiver type");