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"
72 MODULE_AUTHOR("Daniele Peri <peri@csai.unipa.it>");
73 MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver");
74 MODULE_LICENSE("GPL");
76 static int ircc_dma = 255;
77 module_param(ircc_dma, int, 0);
78 MODULE_PARM_DESC(ircc_dma, "DMA channel");
80 static int ircc_irq = 255;
81 module_param(ircc_irq, int, 0);
82 MODULE_PARM_DESC(ircc_irq, "IRQ line");
85 module_param(ircc_fir, int, 0);
86 MODULE_PARM_DESC(ircc_fir, "FIR Base Address");
89 module_param(ircc_sir, int, 0);
90 MODULE_PARM_DESC(ircc_sir, "SIR Base Address");
93 module_param(ircc_cfg, int, 0);
94 MODULE_PARM_DESC(ircc_cfg, "Configuration register base address");
96 static int ircc_transceiver;
97 module_param(ircc_transceiver, int, 0);
98 MODULE_PARM_DESC(ircc_transceiver, "Transceiver type");
102 struct smsc_transceiver {
104 void (*set_for_speed)(int fir_base, u32 speed);
105 int (*probe)(int fir_base);
118 struct smsc_chip_address {
119 unsigned int cfg_base;
123 /* Private data for each instance */
124 struct smsc_ircc_cb {
125 struct net_device *netdev; /* Yes! we are some kind of netdevice */
126 struct net_device_stats stats;
127 struct irlap_cb *irlap; /* The link layer we are binded to */
129 chipio_t io; /* IrDA controller information */
130 iobuff_t tx_buff; /* Transmit buffer */
131 iobuff_t rx_buff; /* Receive buffer */
132 dma_addr_t tx_buff_dma;
133 dma_addr_t rx_buff_dma;
135 struct qos_info qos; /* QoS capabilities for this device */
137 spinlock_t lock; /* For serializing operations */
140 __u32 flags; /* Interface flags */
142 int tx_buff_offsets[10]; /* Offsets between frames in tx_buff */
143 int tx_len; /* Number of frames in tx_buff */
146 struct platform_device *pldev;
151 #define SMSC_IRCC2_DRIVER_NAME "smsc-ircc2"
153 #define SMSC_IRCC2_C_IRDA_FALLBACK_SPEED 9600
154 #define SMSC_IRCC2_C_DEFAULT_TRANSCEIVER 1
155 #define SMSC_IRCC2_C_NET_TIMEOUT 0
156 #define SMSC_IRCC2_C_SIR_STOP 0
158 static const char *driver_name = SMSC_IRCC2_DRIVER_NAME;
162 static int smsc_ircc_open(unsigned int firbase, unsigned int sirbase, u8 dma, u8 irq);
163 static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base);
164 static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq);
165 static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self);
166 static void smsc_ircc_init_chip(struct smsc_ircc_cb *self);
167 static int __exit smsc_ircc_close(struct smsc_ircc_cb *self);
168 static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self);
169 static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self);
170 static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self);
171 static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev);
172 static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev);
173 static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs);
174 static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self);
175 static void smsc_ircc_change_speed(void *priv, u32 speed);
176 static void smsc_ircc_set_sir_speed(void *priv, u32 speed);
177 static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
178 static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev);
179 static void smsc_ircc_sir_start(struct smsc_ircc_cb *self);
180 #if SMSC_IRCC2_C_SIR_STOP
181 static void smsc_ircc_sir_stop(struct smsc_ircc_cb *self);
183 static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self);
184 static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len);
185 static int smsc_ircc_net_open(struct net_device *dev);
186 static int smsc_ircc_net_close(struct net_device *dev);
187 static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
188 #if SMSC_IRCC2_C_NET_TIMEOUT
189 static void smsc_ircc_timeout(struct net_device *dev);
191 static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev);
192 static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self);
193 static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self);
194 static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed);
195 static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self);
198 static int __init smsc_ircc_look_for_chips(void);
199 static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type);
200 static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
201 static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
202 static int __init smsc_superio_fdc(unsigned short cfg_base);
203 static int __init smsc_superio_lpc(unsigned short cfg_base);
205 /* Transceivers specific functions */
207 static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed);
208 static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base);
209 static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed);
210 static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base);
211 static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed);
212 static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base);
214 /* Power Management */
216 static int smsc_ircc_suspend(struct device *dev, pm_message_t state, u32 level);
217 static int smsc_ircc_resume(struct device *dev, u32 level);
219 static struct device_driver smsc_ircc_driver = {
220 .name = SMSC_IRCC2_DRIVER_NAME,
221 .bus = &platform_bus_type,
222 .suspend = smsc_ircc_suspend,
223 .resume = smsc_ircc_resume,
226 /* Transceivers for SMSC-ircc */
228 static struct smsc_transceiver smsc_transceivers[] =
230 { "Toshiba Satellite 1800 (GP data pin select)", smsc_ircc_set_transceiver_toshiba_sat1800, smsc_ircc_probe_transceiver_toshiba_sat1800 },
231 { "Fast pin select", smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select, smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select },
232 { "ATC IRMode", smsc_ircc_set_transceiver_smsc_ircc_atc, smsc_ircc_probe_transceiver_smsc_ircc_atc },
235 #define SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS (ARRAY_SIZE(smsc_transceivers) - 1)
237 /* SMC SuperIO chipsets definitions */
239 #define KEY55_1 0 /* SuperIO Configuration mode with Key <0x55> */
240 #define KEY55_2 1 /* SuperIO Configuration mode with Key <0x55,0x55> */
241 #define NoIRDA 2 /* SuperIO Chip has no IRDA Port */
242 #define SIR 0 /* SuperIO Chip has only slow IRDA */
243 #define FIR 4 /* SuperIO Chip has fast IRDA */
244 #define SERx4 8 /* SuperIO Chip supports 115,2 KBaud * 4=460,8 KBaud */
246 static struct smsc_chip __initdata fdc_chips_flat[] =
248 /* Base address 0x3f0 or 0x370 */
249 { "37C44", KEY55_1|NoIRDA, 0x00, 0x00 }, /* This chip cannot be detected */
250 { "37C665GT", KEY55_2|NoIRDA, 0x65, 0x01 },
251 { "37C665GT", KEY55_2|NoIRDA, 0x66, 0x01 },
252 { "37C669", KEY55_2|SIR|SERx4, 0x03, 0x02 },
253 { "37C669", KEY55_2|SIR|SERx4, 0x04, 0x02 }, /* ID? */
254 { "37C78", KEY55_2|NoIRDA, 0x78, 0x00 },
255 { "37N769", KEY55_1|FIR|SERx4, 0x28, 0x00 },
256 { "37N869", KEY55_1|FIR|SERx4, 0x29, 0x00 },
260 static struct smsc_chip __initdata fdc_chips_paged[] =
262 /* Base address 0x3f0 or 0x370 */
263 { "37B72X", KEY55_1|SIR|SERx4, 0x4c, 0x00 },
264 { "37B77X", KEY55_1|SIR|SERx4, 0x43, 0x00 },
265 { "37B78X", KEY55_1|SIR|SERx4, 0x44, 0x00 },
266 { "37B80X", KEY55_1|SIR|SERx4, 0x42, 0x00 },
267 { "37C67X", KEY55_1|FIR|SERx4, 0x40, 0x00 },
268 { "37C93X", KEY55_2|SIR|SERx4, 0x02, 0x01 },
269 { "37C93XAPM", KEY55_1|SIR|SERx4, 0x30, 0x01 },
270 { "37C93XFR", KEY55_2|FIR|SERx4, 0x03, 0x01 },
271 { "37M707", KEY55_1|SIR|SERx4, 0x42, 0x00 },
272 { "37M81X", KEY55_1|SIR|SERx4, 0x4d, 0x00 },
273 { "37N958FR", KEY55_1|FIR|SERx4, 0x09, 0x04 },
274 { "37N971", KEY55_1|FIR|SERx4, 0x0a, 0x00 },
275 { "37N972", KEY55_1|FIR|SERx4, 0x0b, 0x00 },
279 static struct smsc_chip __initdata lpc_chips_flat[] =
281 /* Base address 0x2E or 0x4E */
282 { "47N227", KEY55_1|FIR|SERx4, 0x5a, 0x00 },
283 { "47N267", KEY55_1|FIR|SERx4, 0x5e, 0x00 },
287 static struct smsc_chip __initdata lpc_chips_paged[] =
289 /* Base address 0x2E or 0x4E */
290 { "47B27X", KEY55_1|SIR|SERx4, 0x51, 0x00 },
291 { "47B37X", KEY55_1|SIR|SERx4, 0x52, 0x00 },
292 { "47M10X", KEY55_1|SIR|SERx4, 0x59, 0x00 },
293 { "47M120", KEY55_1|NoIRDA|SERx4, 0x5c, 0x00 },
294 { "47M13X", KEY55_1|SIR|SERx4, 0x59, 0x00 },
295 { "47M14X", KEY55_1|SIR|SERx4, 0x5f, 0x00 },
296 { "47N252", KEY55_1|FIR|SERx4, 0x0e, 0x00 },
297 { "47S42X", KEY55_1|SIR|SERx4, 0x57, 0x00 },
301 #define SMSCSIO_TYPE_FDC 1
302 #define SMSCSIO_TYPE_LPC 2
303 #define SMSCSIO_TYPE_FLAT 4
304 #define SMSCSIO_TYPE_PAGED 8
306 static struct smsc_chip_address __initdata possible_addresses[] =
308 { 0x3f0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
309 { 0x370, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
310 { 0xe0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
311 { 0x2e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
312 { 0x4e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
318 static struct smsc_ircc_cb *dev_self[] = { NULL, NULL };
319 static unsigned short dev_count;
321 static inline void register_bank(int iobase, int bank)
323 outb(((inb(iobase + IRCC_MASTER) & 0xf0) | (bank & 0x07)),
324 iobase + IRCC_MASTER);
328 /*******************************************************************************
334 *******************************************************************************/
337 * Function smsc_ircc_init ()
339 * Initialize chip. Just try to find out how many chips we are dealing with
342 static int __init smsc_ircc_init(void)
346 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
348 ret = driver_register(&smsc_ircc_driver);
350 IRDA_ERROR("%s, Can't register driver!\n", driver_name);
356 if (ircc_fir > 0 && ircc_sir > 0) {
357 IRDA_MESSAGE(" Overriding FIR address 0x%04x\n", ircc_fir);
358 IRDA_MESSAGE(" Overriding SIR address 0x%04x\n", ircc_sir);
360 if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq))
364 /* try user provided configuration register base address */
366 IRDA_MESSAGE(" Overriding configuration address "
367 "0x%04x\n", ircc_cfg);
368 if (!smsc_superio_fdc(ircc_cfg))
370 if (!smsc_superio_lpc(ircc_cfg))
374 if (smsc_ircc_look_for_chips() > 0)
379 driver_unregister(&smsc_ircc_driver);
385 * Function smsc_ircc_open (firbase, sirbase, dma, irq)
387 * Try to open driver instance
390 static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
392 struct smsc_ircc_cb *self;
393 struct net_device *dev;
396 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
398 err = smsc_ircc_present(fir_base, sir_base);
403 if (dev_count >= ARRAY_SIZE(dev_self)) {
404 IRDA_WARNING("%s(), too many devices!\n", __FUNCTION__);
409 * Allocate new instance of the driver
411 dev = alloc_irdadev(sizeof(struct smsc_ircc_cb));
413 IRDA_WARNING("%s() can't allocate net device\n", __FUNCTION__);
417 SET_MODULE_OWNER(dev);
419 dev->hard_start_xmit = smsc_ircc_hard_xmit_sir;
420 #if SMSC_IRCC2_C_NET_TIMEOUT
421 dev->tx_timeout = smsc_ircc_timeout;
422 dev->watchdog_timeo = HZ * 2; /* Allow enough time for speed change */
424 dev->open = smsc_ircc_net_open;
425 dev->stop = smsc_ircc_net_close;
426 dev->do_ioctl = smsc_ircc_net_ioctl;
427 dev->get_stats = smsc_ircc_net_get_stats;
432 /* Make ifconfig display some details */
433 dev->base_addr = self->io.fir_base = fir_base;
434 dev->irq = self->io.irq = irq;
436 /* Need to store self somewhere */
437 dev_self[dev_count] = self;
438 spin_lock_init(&self->lock);
440 self->rx_buff.truesize = SMSC_IRCC2_RX_BUFF_TRUESIZE;
441 self->tx_buff.truesize = SMSC_IRCC2_TX_BUFF_TRUESIZE;
444 dma_alloc_coherent(NULL, self->rx_buff.truesize,
445 &self->rx_buff_dma, GFP_KERNEL);
446 if (self->rx_buff.head == NULL) {
447 IRDA_ERROR("%s, Can't allocate memory for receive buffer!\n",
453 dma_alloc_coherent(NULL, self->tx_buff.truesize,
454 &self->tx_buff_dma, GFP_KERNEL);
455 if (self->tx_buff.head == NULL) {
456 IRDA_ERROR("%s, Can't allocate memory for transmit buffer!\n",
461 memset(self->rx_buff.head, 0, self->rx_buff.truesize);
462 memset(self->tx_buff.head, 0, self->tx_buff.truesize);
464 self->rx_buff.in_frame = FALSE;
465 self->rx_buff.state = OUTSIDE_FRAME;
466 self->tx_buff.data = self->tx_buff.head;
467 self->rx_buff.data = self->rx_buff.head;
469 smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq);
470 smsc_ircc_setup_qos(self);
471 smsc_ircc_init_chip(self);
473 if (ircc_transceiver > 0 &&
474 ircc_transceiver < SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS)
475 self->transceiver = ircc_transceiver;
477 smsc_ircc_probe_transceiver(self);
479 err = register_netdev(self->netdev);
481 IRDA_ERROR("%s, Network device registration failed!\n",
486 self->pldev = platform_device_register_simple(SMSC_IRCC2_DRIVER_NAME,
488 if (IS_ERR(self->pldev)) {
489 err = PTR_ERR(self->pldev);
492 dev_set_drvdata(&self->pldev->dev, self);
494 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
500 unregister_netdev(self->netdev);
503 dma_free_coherent(NULL, self->tx_buff.truesize,
504 self->tx_buff.head, self->tx_buff_dma);
506 dma_free_coherent(NULL, self->rx_buff.truesize,
507 self->rx_buff.head, self->rx_buff_dma);
509 free_netdev(self->netdev);
510 dev_self[dev_count] = NULL;
512 release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
513 release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
519 * Function smsc_ircc_present(fir_base, sir_base)
521 * Check the smsc-ircc chip presence
524 static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base)
526 unsigned char low, high, chip, config, dma, irq, version;
528 if (!request_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT,
530 IRDA_WARNING("%s: can't get fir_base of 0x%03x\n",
531 __FUNCTION__, fir_base);
535 if (!request_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT,
537 IRDA_WARNING("%s: can't get sir_base of 0x%03x\n",
538 __FUNCTION__, sir_base);
542 register_bank(fir_base, 3);
544 high = inb(fir_base + IRCC_ID_HIGH);
545 low = inb(fir_base + IRCC_ID_LOW);
546 chip = inb(fir_base + IRCC_CHIP_ID);
547 version = inb(fir_base + IRCC_VERSION);
548 config = inb(fir_base + IRCC_INTERFACE);
549 dma = config & IRCC_INTERFACE_DMA_MASK;
550 irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4;
552 if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) {
553 IRDA_WARNING("%s(), addr 0x%04x - no device found!\n",
554 __FUNCTION__, fir_base);
557 IRDA_MESSAGE("SMsC IrDA Controller found\n IrCC version %d.%d, "
558 "firport 0x%03x, sirport 0x%03x dma=%d, irq=%d\n",
559 chip & 0x0f, version, fir_base, sir_base, dma, irq);
564 release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
566 release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
572 * Function smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq)
577 static void smsc_ircc_setup_io(struct smsc_ircc_cb *self,
578 unsigned int fir_base, unsigned int sir_base,
581 unsigned char config, chip_dma, chip_irq;
583 register_bank(fir_base, 3);
584 config = inb(fir_base + IRCC_INTERFACE);
585 chip_dma = config & IRCC_INTERFACE_DMA_MASK;
586 chip_irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4;
588 self->io.fir_base = fir_base;
589 self->io.sir_base = sir_base;
590 self->io.fir_ext = SMSC_IRCC2_FIR_CHIP_IO_EXTENT;
591 self->io.sir_ext = SMSC_IRCC2_SIR_CHIP_IO_EXTENT;
592 self->io.fifo_size = SMSC_IRCC2_FIFO_SIZE;
593 self->io.speed = SMSC_IRCC2_C_IRDA_FALLBACK_SPEED;
597 IRDA_MESSAGE("%s, Overriding IRQ - chip says %d, using %d\n",
598 driver_name, chip_irq, irq);
601 self->io.irq = chip_irq;
605 IRDA_MESSAGE("%s, Overriding DMA - chip says %d, using %d\n",
606 driver_name, chip_dma, dma);
609 self->io.dma = chip_dma;
614 * Function smsc_ircc_setup_qos(self)
619 static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self)
621 /* Initialize QoS for this device */
622 irda_init_max_qos_capabilies(&self->qos);
624 self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|
625 IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8);
627 self->qos.min_turn_time.bits = SMSC_IRCC2_MIN_TURN_TIME;
628 self->qos.window_size.bits = SMSC_IRCC2_WINDOW_SIZE;
629 irda_qos_bits_to_value(&self->qos);
633 * Function smsc_ircc_init_chip(self)
638 static void smsc_ircc_init_chip(struct smsc_ircc_cb *self)
640 int iobase, ir_mode, ctrl, fast;
642 IRDA_ASSERT(self != NULL, return;);
644 iobase = self->io.fir_base;
645 ir_mode = IRCC_CFGA_IRDA_SIR_A;
649 register_bank(iobase, 0);
650 outb(IRCC_MASTER_RESET, iobase + IRCC_MASTER);
651 outb(0x00, iobase + IRCC_MASTER);
653 register_bank(iobase, 1);
654 outb(((inb(iobase + IRCC_SCE_CFGA) & 0x87) | ir_mode),
655 iobase + IRCC_SCE_CFGA);
657 #ifdef smsc_669 /* Uses pin 88/89 for Rx/Tx */
658 outb(((inb(iobase + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM),
659 iobase + IRCC_SCE_CFGB);
661 outb(((inb(iobase + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR),
662 iobase + IRCC_SCE_CFGB);
664 (void) inb(iobase + IRCC_FIFO_THRESHOLD);
665 outb(SMSC_IRCC2_FIFO_THRESHOLD, iobase + IRCC_FIFO_THRESHOLD);
667 register_bank(iobase, 4);
668 outb((inb(iobase + IRCC_CONTROL) & 0x30) | ctrl, iobase + IRCC_CONTROL);
670 register_bank(iobase, 0);
671 outb(fast, iobase + IRCC_LCR_A);
673 smsc_ircc_set_sir_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED);
675 /* Power on device */
676 outb(0x00, iobase + IRCC_MASTER);
680 * Function smsc_ircc_net_ioctl (dev, rq, cmd)
682 * Process IOCTL commands for this device
685 static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
687 struct if_irda_req *irq = (struct if_irda_req *) rq;
688 struct smsc_ircc_cb *self;
692 IRDA_ASSERT(dev != NULL, return -1;);
696 IRDA_ASSERT(self != NULL, return -1;);
698 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd);
701 case SIOCSBANDWIDTH: /* Set bandwidth */
702 if (!capable(CAP_NET_ADMIN))
705 /* Make sure we are the only one touching
706 * self->io.speed and the hardware - Jean II */
707 spin_lock_irqsave(&self->lock, flags);
708 smsc_ircc_change_speed(self, irq->ifr_baudrate);
709 spin_unlock_irqrestore(&self->lock, flags);
712 case SIOCSMEDIABUSY: /* Set media busy */
713 if (!capable(CAP_NET_ADMIN)) {
718 irda_device_set_media_busy(self->netdev, TRUE);
720 case SIOCGRECEIVING: /* Check if we are receiving right now */
721 irq->ifr_receiving = smsc_ircc_is_receiving(self);
725 if (!capable(CAP_NET_ADMIN)) {
729 smsc_ircc_sir_set_dtr_rts(dev, irq->ifr_dtr, irq->ifr_rts);
739 static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev)
741 struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) dev->priv;
746 #if SMSC_IRCC2_C_NET_TIMEOUT
748 * Function smsc_ircc_timeout (struct net_device *dev)
750 * The networking timeout management.
754 static void smsc_ircc_timeout(struct net_device *dev)
756 struct smsc_ircc_cb *self;
759 self = (struct smsc_ircc_cb *) dev->priv;
761 IRDA_WARNING("%s: transmit timed out, changing speed to: %d\n",
762 dev->name, self->io.speed);
763 spin_lock_irqsave(&self->lock, flags);
764 smsc_ircc_sir_start(self);
765 smsc_ircc_change_speed(self, self->io.speed);
766 dev->trans_start = jiffies;
767 netif_wake_queue(dev);
768 spin_unlock_irqrestore(&self->lock, flags);
773 * Function smsc_ircc_hard_xmit_sir (struct sk_buff *skb, struct net_device *dev)
775 * Transmits the current frame until FIFO is full, then
776 * waits until the next transmit interrupt, and continues until the
777 * frame is transmitted.
779 int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
781 struct smsc_ircc_cb *self;
785 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
787 IRDA_ASSERT(dev != NULL, return 0;);
789 self = (struct smsc_ircc_cb *) dev->priv;
790 IRDA_ASSERT(self != NULL, return 0;);
792 netif_stop_queue(dev);
794 /* Make sure test of self->io.speed & speed change are atomic */
795 spin_lock_irqsave(&self->lock, flags);
797 /* Check if we need to change the speed */
798 speed = irda_get_next_speed(skb);
799 if (speed != self->io.speed && speed != -1) {
800 /* Check for empty frame */
803 * We send frames one by one in SIR mode (no
804 * pipelining), so at this point, if we were sending
805 * a previous frame, we just received the interrupt
806 * telling us it is finished (UART_IIR_THRI).
807 * Therefore, waiting for the transmitter to really
808 * finish draining the fifo won't take too long.
809 * And the interrupt handler is not expected to run.
811 smsc_ircc_sir_wait_hw_transmitter_finish(self);
812 smsc_ircc_change_speed(self, speed);
813 spin_unlock_irqrestore(&self->lock, flags);
817 self->new_speed = speed;
821 self->tx_buff.data = self->tx_buff.head;
823 /* Copy skb to tx_buff while wrapping, stuffing and making CRC */
824 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
825 self->tx_buff.truesize);
827 self->stats.tx_bytes += self->tx_buff.len;
829 /* Turn on transmit finished interrupt. Will fire immediately! */
830 outb(UART_IER_THRI, self->io.sir_base + UART_IER);
832 spin_unlock_irqrestore(&self->lock, flags);
840 * Function smsc_ircc_set_fir_speed (self, baud)
842 * Change the speed of the device
845 static void smsc_ircc_set_fir_speed(struct smsc_ircc_cb *self, u32 speed)
847 int fir_base, ir_mode, ctrl, fast;
849 IRDA_ASSERT(self != NULL, return;);
850 fir_base = self->io.fir_base;
852 self->io.speed = speed;
857 ir_mode = IRCC_CFGA_IRDA_HDLC;
860 IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __FUNCTION__);
863 ir_mode = IRCC_CFGA_IRDA_HDLC;
864 ctrl = IRCC_1152 | IRCC_CRC;
865 fast = IRCC_LCR_A_FAST | IRCC_LCR_A_GP_DATA;
866 IRDA_DEBUG(0, "%s(), handling baud of 1152000\n",
870 ir_mode = IRCC_CFGA_IRDA_4PPM;
872 fast = IRCC_LCR_A_FAST;
873 IRDA_DEBUG(0, "%s(), handling baud of 4000000\n",
879 /* This causes an interrupt */
880 register_bank(fir_base, 0);
881 outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast, fir_base + IRCC_LCR_A);
884 register_bank(fir_base, 1);
885 outb(((inb(fir_base + IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | ir_mode), fir_base + IRCC_SCE_CFGA);
887 register_bank(fir_base, 4);
888 outb((inb(fir_base + IRCC_CONTROL) & 0x30) | ctrl, fir_base + IRCC_CONTROL);
892 * Function smsc_ircc_fir_start(self)
894 * Change the speed of the device
897 static void smsc_ircc_fir_start(struct smsc_ircc_cb *self)
899 struct net_device *dev;
902 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
904 IRDA_ASSERT(self != NULL, return;);
906 IRDA_ASSERT(dev != NULL, return;);
908 fir_base = self->io.fir_base;
910 /* Reset everything */
912 /* Install FIR transmit handler */
913 dev->hard_start_xmit = smsc_ircc_hard_xmit_fir;
916 outb(inb(fir_base + IRCC_LCR_A) | IRCC_LCR_A_FIFO_RESET, fir_base + IRCC_LCR_A);
918 /* Enable interrupt */
919 /*outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, fir_base + IRCC_IER);*/
921 register_bank(fir_base, 1);
923 /* Select the TX/RX interface */
924 #ifdef SMSC_669 /* Uses pin 88/89 for Rx/Tx */
925 outb(((inb(fir_base + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM),
926 fir_base + IRCC_SCE_CFGB);
928 outb(((inb(fir_base + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR),
929 fir_base + IRCC_SCE_CFGB);
931 (void) inb(fir_base + IRCC_FIFO_THRESHOLD);
933 /* Enable SCE interrupts */
934 outb(0, fir_base + IRCC_MASTER);
935 register_bank(fir_base, 0);
936 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, fir_base + IRCC_IER);
937 outb(IRCC_MASTER_INT_EN, fir_base + IRCC_MASTER);
941 * Function smsc_ircc_fir_stop(self, baud)
943 * Change the speed of the device
946 static void smsc_ircc_fir_stop(struct smsc_ircc_cb *self)
950 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
952 IRDA_ASSERT(self != NULL, return;);
954 fir_base = self->io.fir_base;
955 register_bank(fir_base, 0);
956 /*outb(IRCC_MASTER_RESET, fir_base + IRCC_MASTER);*/
957 outb(inb(fir_base + IRCC_LCR_B) & IRCC_LCR_B_SIP_ENABLE, fir_base + IRCC_LCR_B);
962 * Function smsc_ircc_change_speed(self, baud)
964 * Change the speed of the device
966 * This function *must* be called with spinlock held, because it may
967 * be called from the irq handler. - Jean II
969 static void smsc_ircc_change_speed(void *priv, u32 speed)
971 struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) priv;
972 struct net_device *dev;
973 int last_speed_was_sir;
975 IRDA_DEBUG(0, "%s() changing speed to: %d\n", __FUNCTION__, speed);
977 IRDA_ASSERT(self != NULL, return;);
980 last_speed_was_sir = self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED;
985 self->io.speed = speed;
986 last_speed_was_sir = 0;
987 smsc_ircc_fir_start(self);
990 if (self->io.speed == 0)
991 smsc_ircc_sir_start(self);
994 if (!last_speed_was_sir) speed = self->io.speed;
997 if (self->io.speed != speed)
998 smsc_ircc_set_transceiver_for_speed(self, speed);
1000 self->io.speed = speed;
1002 if (speed <= SMSC_IRCC2_MAX_SIR_SPEED) {
1003 if (!last_speed_was_sir) {
1004 smsc_ircc_fir_stop(self);
1005 smsc_ircc_sir_start(self);
1007 smsc_ircc_set_sir_speed(self, speed);
1009 if (last_speed_was_sir) {
1010 #if SMSC_IRCC2_C_SIR_STOP
1011 smsc_ircc_sir_stop(self);
1013 smsc_ircc_fir_start(self);
1015 smsc_ircc_set_fir_speed(self, speed);
1018 self->tx_buff.len = 10;
1019 self->tx_buff.data = self->tx_buff.head;
1021 smsc_ircc_dma_xmit(self, 4000);
1023 /* Be ready for incoming frames */
1024 smsc_ircc_dma_receive(self);
1027 netif_wake_queue(dev);
1031 * Function smsc_ircc_set_sir_speed (self, speed)
1033 * Set speed of IrDA port to specified baudrate
1036 void smsc_ircc_set_sir_speed(void *priv, __u32 speed)
1038 struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) priv;
1040 int fcr; /* FIFO control reg */
1041 int lcr; /* Line control reg */
1044 IRDA_DEBUG(0, "%s(), Setting speed to: %d\n", __FUNCTION__, speed);
1046 IRDA_ASSERT(self != NULL, return;);
1047 iobase = self->io.sir_base;
1049 /* Update accounting for new speed */
1050 self->io.speed = speed;
1052 /* Turn off interrupts */
1053 outb(0, iobase + UART_IER);
1055 divisor = SMSC_IRCC2_MAX_SIR_SPEED / speed;
1057 fcr = UART_FCR_ENABLE_FIFO;
1060 * Use trigger level 1 to avoid 3 ms. timeout delay at 9600 bps, and
1061 * almost 1,7 ms at 19200 bps. At speeds above that we can just forget
1062 * about this timeout since it will always be fast enough.
1064 fcr |= self->io.speed < 38400 ?
1065 UART_FCR_TRIGGER_1 : UART_FCR_TRIGGER_14;
1067 /* IrDA ports use 8N1 */
1068 lcr = UART_LCR_WLEN8;
1070 outb(UART_LCR_DLAB | lcr, iobase + UART_LCR); /* Set DLAB */
1071 outb(divisor & 0xff, iobase + UART_DLL); /* Set speed */
1072 outb(divisor >> 8, iobase + UART_DLM);
1073 outb(lcr, iobase + UART_LCR); /* Set 8N1 */
1074 outb(fcr, iobase + UART_FCR); /* Enable FIFO's */
1076 /* Turn on interrups */
1077 outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER);
1079 IRDA_DEBUG(2, "%s() speed changed to: %d\n", __FUNCTION__, speed);
1084 * Function smsc_ircc_hard_xmit_fir (skb, dev)
1086 * Transmit the frame!
1089 static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev)
1091 struct smsc_ircc_cb *self;
1092 unsigned long flags;
1096 IRDA_ASSERT(dev != NULL, return 0;);
1097 self = (struct smsc_ircc_cb *) dev->priv;
1098 IRDA_ASSERT(self != NULL, return 0;);
1100 netif_stop_queue(dev);
1102 /* Make sure test of self->io.speed & speed change are atomic */
1103 spin_lock_irqsave(&self->lock, flags);
1105 /* Check if we need to change the speed after this frame */
1106 speed = irda_get_next_speed(skb);
1107 if (speed != self->io.speed && speed != -1) {
1108 /* Check for empty frame */
1110 /* Note : you should make sure that speed changes
1111 * are not going to corrupt any outgoing frame.
1112 * Look at nsc-ircc for the gory details - Jean II */
1113 smsc_ircc_change_speed(self, speed);
1114 spin_unlock_irqrestore(&self->lock, flags);
1119 self->new_speed = speed;
1122 memcpy(self->tx_buff.head, skb->data, skb->len);
1124 self->tx_buff.len = skb->len;
1125 self->tx_buff.data = self->tx_buff.head;
1127 mtt = irda_get_mtt(skb);
1132 * Compute how many BOFs (STA or PA's) we need to waste the
1133 * min turn time given the speed of the link.
1135 bofs = mtt * (self->io.speed / 1000) / 8000;
1139 smsc_ircc_dma_xmit(self, bofs);
1141 /* Transmit frame */
1142 smsc_ircc_dma_xmit(self, 0);
1145 spin_unlock_irqrestore(&self->lock, flags);
1152 * Function smsc_ircc_dma_xmit (self, bofs)
1154 * Transmit data using DMA
1157 static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs)
1159 int iobase = self->io.fir_base;
1162 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1165 register_bank(iobase, 0);
1166 outb(0x00, iobase + IRCC_LCR_B);
1168 register_bank(iobase, 1);
1169 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1170 iobase + IRCC_SCE_CFGB);
1172 self->io.direction = IO_XMIT;
1174 /* Set BOF additional count for generating the min turn time */
1175 register_bank(iobase, 4);
1176 outb(bofs & 0xff, iobase + IRCC_BOF_COUNT_LO);
1177 ctrl = inb(iobase + IRCC_CONTROL) & 0xf0;
1178 outb(ctrl | ((bofs >> 8) & 0x0f), iobase + IRCC_BOF_COUNT_HI);
1180 /* Set max Tx frame size */
1181 outb(self->tx_buff.len >> 8, iobase + IRCC_TX_SIZE_HI);
1182 outb(self->tx_buff.len & 0xff, iobase + IRCC_TX_SIZE_LO);
1184 /*outb(UART_MCR_OUT2, self->io.sir_base + UART_MCR);*/
1186 /* Enable burst mode chip Tx DMA */
1187 register_bank(iobase, 1);
1188 outb(inb(iobase + IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE |
1189 IRCC_CFGB_DMA_BURST, iobase + IRCC_SCE_CFGB);
1191 /* Setup DMA controller (must be done after enabling chip DMA) */
1192 irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
1195 /* Enable interrupt */
1197 register_bank(iobase, 0);
1198 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
1199 outb(IRCC_MASTER_INT_EN, iobase + IRCC_MASTER);
1201 /* Enable transmit */
1202 outb(IRCC_LCR_B_SCE_TRANSMIT | IRCC_LCR_B_SIP_ENABLE, iobase + IRCC_LCR_B);
1206 * Function smsc_ircc_dma_xmit_complete (self)
1208 * The transfer of a frame in finished. This function will only be called
1209 * by the interrupt handler
1212 static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self)
1214 int iobase = self->io.fir_base;
1216 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1219 register_bank(iobase, 0);
1220 outb(0x00, iobase + IRCC_LCR_B);
1222 register_bank(iobase, 1);
1223 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1224 iobase + IRCC_SCE_CFGB);
1226 /* Check for underrun! */
1227 register_bank(iobase, 0);
1228 if (inb(iobase + IRCC_LSR) & IRCC_LSR_UNDERRUN) {
1229 self->stats.tx_errors++;
1230 self->stats.tx_fifo_errors++;
1232 /* Reset error condition */
1233 register_bank(iobase, 0);
1234 outb(IRCC_MASTER_ERROR_RESET, iobase + IRCC_MASTER);
1235 outb(0x00, iobase + IRCC_MASTER);
1237 self->stats.tx_packets++;
1238 self->stats.tx_bytes += self->tx_buff.len;
1241 /* Check if it's time to change the speed */
1242 if (self->new_speed) {
1243 smsc_ircc_change_speed(self, self->new_speed);
1244 self->new_speed = 0;
1247 netif_wake_queue(self->netdev);
1251 * Function smsc_ircc_dma_receive(self)
1253 * Get ready for receiving a frame. The device will initiate a DMA
1254 * if it starts to receive a frame.
1257 static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self)
1259 int iobase = self->io.fir_base;
1261 /* Turn off chip DMA */
1262 register_bank(iobase, 1);
1263 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1264 iobase + IRCC_SCE_CFGB);
1268 register_bank(iobase, 0);
1269 outb(0x00, iobase + IRCC_LCR_B);
1271 /* Turn off chip DMA */
1272 register_bank(iobase, 1);
1273 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1274 iobase + IRCC_SCE_CFGB);
1276 self->io.direction = IO_RECV;
1277 self->rx_buff.data = self->rx_buff.head;
1279 /* Set max Rx frame size */
1280 register_bank(iobase, 4);
1281 outb((2050 >> 8) & 0x0f, iobase + IRCC_RX_SIZE_HI);
1282 outb(2050 & 0xff, iobase + IRCC_RX_SIZE_LO);
1284 /* Setup DMA controller */
1285 irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
1288 /* Enable burst mode chip Rx DMA */
1289 register_bank(iobase, 1);
1290 outb(inb(iobase + IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE |
1291 IRCC_CFGB_DMA_BURST, iobase + IRCC_SCE_CFGB);
1293 /* Enable interrupt */
1294 register_bank(iobase, 0);
1295 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
1296 outb(IRCC_MASTER_INT_EN, iobase + IRCC_MASTER);
1298 /* Enable receiver */
1299 register_bank(iobase, 0);
1300 outb(IRCC_LCR_B_SCE_RECEIVE | IRCC_LCR_B_SIP_ENABLE,
1301 iobase + IRCC_LCR_B);
1307 * Function smsc_ircc_dma_receive_complete(self)
1309 * Finished with receiving frames
1312 static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self)
1314 struct sk_buff *skb;
1315 int len, msgcnt, lsr;
1316 int iobase = self->io.fir_base;
1318 register_bank(iobase, 0);
1320 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1323 register_bank(iobase, 0);
1324 outb(0x00, iobase + IRCC_LCR_B);
1326 register_bank(iobase, 0);
1327 outb(inb(iobase + IRCC_LSAR) & ~IRCC_LSAR_ADDRESS_MASK, iobase + IRCC_LSAR);
1328 lsr= inb(iobase + IRCC_LSR);
1329 msgcnt = inb(iobase + IRCC_LCR_B) & 0x08;
1331 IRDA_DEBUG(2, "%s: dma count = %d\n", __FUNCTION__,
1332 get_dma_residue(self->io.dma));
1334 len = self->rx_buff.truesize - get_dma_residue(self->io.dma);
1336 /* Look for errors */
1337 if (lsr & (IRCC_LSR_FRAME_ERROR | IRCC_LSR_CRC_ERROR | IRCC_LSR_SIZE_ERROR)) {
1338 self->stats.rx_errors++;
1339 if (lsr & IRCC_LSR_FRAME_ERROR)
1340 self->stats.rx_frame_errors++;
1341 if (lsr & IRCC_LSR_CRC_ERROR)
1342 self->stats.rx_crc_errors++;
1343 if (lsr & IRCC_LSR_SIZE_ERROR)
1344 self->stats.rx_length_errors++;
1345 if (lsr & (IRCC_LSR_UNDERRUN | IRCC_LSR_OVERRUN))
1346 self->stats.rx_length_errors++;
1351 len -= self->io.speed < 4000000 ? 2 : 4;
1353 if (len < 2 || len > 2050) {
1354 IRDA_WARNING("%s(), bogus len=%d\n", __FUNCTION__, len);
1357 IRDA_DEBUG(2, "%s: msgcnt = %d, len=%d\n", __FUNCTION__, msgcnt, len);
1359 skb = dev_alloc_skb(len + 1);
1361 IRDA_WARNING("%s(), memory squeeze, dropping frame.\n",
1365 /* Make sure IP header gets aligned */
1366 skb_reserve(skb, 1);
1368 memcpy(skb_put(skb, len), self->rx_buff.data, len);
1369 self->stats.rx_packets++;
1370 self->stats.rx_bytes += len;
1372 skb->dev = self->netdev;
1373 skb->mac.raw = skb->data;
1374 skb->protocol = htons(ETH_P_IRDA);
1379 * Function smsc_ircc_sir_receive (self)
1381 * Receive one frame from the infrared port
1384 static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self)
1389 IRDA_ASSERT(self != NULL, return;);
1391 iobase = self->io.sir_base;
1394 * Receive all characters in Rx FIFO, unwrap and unstuff them.
1395 * async_unwrap_char will deliver all found frames
1398 async_unwrap_char(self->netdev, &self->stats, &self->rx_buff,
1399 inb(iobase + UART_RX));
1401 /* Make sure we don't stay here to long */
1402 if (boguscount++ > 32) {
1403 IRDA_DEBUG(2, "%s(), breaking!\n", __FUNCTION__);
1406 } while (inb(iobase + UART_LSR) & UART_LSR_DR);
1411 * Function smsc_ircc_interrupt (irq, dev_id, regs)
1413 * An interrupt from the chip has arrived. Time to do some work
1416 static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1418 struct net_device *dev = (struct net_device *) dev_id;
1419 struct smsc_ircc_cb *self;
1420 int iobase, iir, lcra, lsr;
1421 irqreturn_t ret = IRQ_NONE;
1424 printk(KERN_WARNING "%s: irq %d for unknown device.\n",
1428 self = (struct smsc_ircc_cb *) dev->priv;
1429 IRDA_ASSERT(self != NULL, return IRQ_NONE;);
1431 /* Serialise the interrupt handler in various CPUs, stop Tx path */
1432 spin_lock(&self->lock);
1434 /* Check if we should use the SIR interrupt handler */
1435 if (self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED) {
1436 ret = smsc_ircc_interrupt_sir(dev);
1437 goto irq_ret_unlock;
1440 iobase = self->io.fir_base;
1442 register_bank(iobase, 0);
1443 iir = inb(iobase + IRCC_IIR);
1445 goto irq_ret_unlock;
1448 /* Disable interrupts */
1449 outb(0, iobase + IRCC_IER);
1450 lcra = inb(iobase + IRCC_LCR_A);
1451 lsr = inb(iobase + IRCC_LSR);
1453 IRDA_DEBUG(2, "%s(), iir = 0x%02x\n", __FUNCTION__, iir);
1455 if (iir & IRCC_IIR_EOM) {
1456 if (self->io.direction == IO_RECV)
1457 smsc_ircc_dma_receive_complete(self);
1459 smsc_ircc_dma_xmit_complete(self);
1461 smsc_ircc_dma_receive(self);
1464 if (iir & IRCC_IIR_ACTIVE_FRAME) {
1465 /*printk(KERN_WARNING "%s(): Active Frame\n", __FUNCTION__);*/
1468 /* Enable interrupts again */
1470 register_bank(iobase, 0);
1471 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
1474 spin_unlock(&self->lock);
1480 * Function irport_interrupt_sir (irq, dev_id, regs)
1482 * Interrupt handler for SIR modes
1484 static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev)
1486 struct smsc_ircc_cb *self = dev->priv;
1491 /* Already locked comming here in smsc_ircc_interrupt() */
1492 /*spin_lock(&self->lock);*/
1494 iobase = self->io.sir_base;
1496 iir = inb(iobase + UART_IIR) & UART_IIR_ID;
1500 /* Clear interrupt */
1501 lsr = inb(iobase + UART_LSR);
1503 IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n",
1504 __FUNCTION__, iir, lsr, iobase);
1508 IRDA_DEBUG(2, "%s(), RLSI\n", __FUNCTION__);
1511 /* Receive interrupt */
1512 smsc_ircc_sir_receive(self);
1515 if (lsr & UART_LSR_THRE)
1516 /* Transmitter ready for data */
1517 smsc_ircc_sir_write_wakeup(self);
1520 IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n",
1525 /* Make sure we don't stay here to long */
1526 if (boguscount++ > 100)
1529 iir = inb(iobase + UART_IIR) & UART_IIR_ID;
1531 /*spin_unlock(&self->lock);*/
1538 * Function ircc_is_receiving (self)
1540 * Return TRUE is we are currently receiving a frame
1543 static int ircc_is_receiving(struct smsc_ircc_cb *self)
1548 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1550 IRDA_ASSERT(self != NULL, return FALSE;);
1552 IRDA_DEBUG(0, "%s: dma count = %d\n", __FUNCTION__,
1553 get_dma_residue(self->io.dma));
1555 status = (self->rx_buff.state != OUTSIDE_FRAME);
1563 * Function smsc_ircc_net_open (dev)
1568 static int smsc_ircc_net_open(struct net_device *dev)
1570 struct smsc_ircc_cb *self;
1572 unsigned long flags;
1574 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1576 IRDA_ASSERT(dev != NULL, return -1;);
1577 self = (struct smsc_ircc_cb *) dev->priv;
1578 IRDA_ASSERT(self != NULL, return 0;);
1580 if (request_irq(self->io.irq, smsc_ircc_interrupt, 0, dev->name,
1582 IRDA_DEBUG(0, "%s(), unable to allocate irq=%d\n",
1583 __FUNCTION__, self->io.irq);
1587 spin_lock_irqsave(&self->lock, flags);
1588 /*smsc_ircc_sir_start(self);*/
1590 smsc_ircc_change_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED);
1591 spin_unlock_irqrestore(&self->lock, flags);
1593 /* Give self a hardware name */
1594 /* It would be cool to offer the chip revision here - Jean II */
1595 sprintf(hwname, "SMSC @ 0x%03x", self->io.fir_base);
1598 * Open new IrLAP layer instance, now that everything should be
1599 * initialized properly
1601 self->irlap = irlap_open(dev, &self->qos, hwname);
1604 * Always allocate the DMA channel after the IRQ,
1605 * and clean up on failure.
1607 if (request_dma(self->io.dma, dev->name)) {
1608 smsc_ircc_net_close(dev);
1610 IRDA_WARNING("%s(), unable to allocate DMA=%d\n",
1611 __FUNCTION__, self->io.dma);
1615 netif_start_queue(dev);
1621 * Function smsc_ircc_net_close (dev)
1626 static int smsc_ircc_net_close(struct net_device *dev)
1628 struct smsc_ircc_cb *self;
1630 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1632 IRDA_ASSERT(dev != NULL, return -1;);
1633 self = (struct smsc_ircc_cb *) dev->priv;
1634 IRDA_ASSERT(self != NULL, return 0;);
1637 netif_stop_queue(dev);
1639 /* Stop and remove instance of IrLAP */
1641 irlap_close(self->irlap);
1644 free_irq(self->io.irq, dev);
1645 disable_dma(self->io.dma);
1646 free_dma(self->io.dma);
1651 static int smsc_ircc_suspend(struct device *dev, pm_message_t state, u32 level)
1653 struct smsc_ircc_cb *self = dev_get_drvdata(dev);
1655 IRDA_MESSAGE("%s, Suspending\n", driver_name);
1657 if (level == SUSPEND_DISABLE && !self->io.suspended) {
1658 smsc_ircc_net_close(self->netdev);
1659 self->io.suspended = 1;
1665 static int smsc_ircc_resume(struct device *dev, u32 level)
1667 struct smsc_ircc_cb *self = dev_get_drvdata(dev);
1669 if (level == RESUME_ENABLE && self->io.suspended) {
1671 smsc_ircc_net_open(self->netdev);
1672 self->io.suspended = 0;
1674 IRDA_MESSAGE("%s, Waking up\n", driver_name);
1680 * Function smsc_ircc_close (self)
1682 * Close driver instance
1685 static int __exit smsc_ircc_close(struct smsc_ircc_cb *self)
1688 unsigned long flags;
1690 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1692 IRDA_ASSERT(self != NULL, return -1;);
1694 platform_device_unregister(self->pldev);
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 iobase = self->io.fir_base;
1704 register_bank(iobase, 0);
1705 outb(0, iobase + IRCC_IER);
1706 outb(IRCC_MASTER_RESET, iobase + IRCC_MASTER);
1707 outb(0x00, iobase + IRCC_MASTER);
1709 /* Reset to SIR mode */
1710 register_bank(iobase, 1);
1711 outb(IRCC_CFGA_IRDA_SIR_A|IRCC_CFGA_TX_POLARITY, iobase + IRCC_SCE_CFGA);
1712 outb(IRCC_CFGB_IR, iobase + IRCC_SCE_CFGB);
1714 spin_unlock_irqrestore(&self->lock, flags);
1716 /* Release the PORTS that this driver is using */
1717 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__,
1720 release_region(self->io.fir_base, self->io.fir_ext);
1722 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__,
1725 release_region(self->io.sir_base, self->io.sir_ext);
1727 if (self->tx_buff.head)
1728 dma_free_coherent(NULL, self->tx_buff.truesize,
1729 self->tx_buff.head, self->tx_buff_dma);
1731 if (self->rx_buff.head)
1732 dma_free_coherent(NULL, self->rx_buff.truesize,
1733 self->rx_buff.head, self->rx_buff_dma);
1735 free_netdev(self->netdev);
1740 static void __exit smsc_ircc_cleanup(void)
1744 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1746 for (i = 0; i < 2; i++) {
1748 smsc_ircc_close(dev_self[i]);
1751 driver_unregister(&smsc_ircc_driver);
1755 * Start SIR operations
1757 * This function *must* be called with spinlock held, because it may
1758 * be called from the irq handler (via smsc_ircc_change_speed()). - Jean II
1760 void smsc_ircc_sir_start(struct smsc_ircc_cb *self)
1762 struct net_device *dev;
1763 int fir_base, sir_base;
1765 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1767 IRDA_ASSERT(self != NULL, return;);
1769 IRDA_ASSERT(dev != NULL, return;);
1770 dev->hard_start_xmit = &smsc_ircc_hard_xmit_sir;
1772 fir_base = self->io.fir_base;
1773 sir_base = self->io.sir_base;
1775 /* Reset everything */
1776 outb(IRCC_MASTER_RESET, fir_base + IRCC_MASTER);
1778 #if SMSC_IRCC2_C_SIR_STOP
1779 /*smsc_ircc_sir_stop(self);*/
1782 register_bank(fir_base, 1);
1783 outb(((inb(fir_base + IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | IRCC_CFGA_IRDA_SIR_A), fir_base + IRCC_SCE_CFGA);
1785 /* Initialize UART */
1786 outb(UART_LCR_WLEN8, sir_base + UART_LCR); /* Reset DLAB */
1787 outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), sir_base + UART_MCR);
1789 /* Turn on interrups */
1790 outb(UART_IER_RLSI | UART_IER_RDI |UART_IER_THRI, sir_base + UART_IER);
1792 IRDA_DEBUG(3, "%s() - exit\n", __FUNCTION__);
1794 outb(0x00, fir_base + IRCC_MASTER);
1797 #if SMSC_IRCC2_C_SIR_STOP
1798 void smsc_ircc_sir_stop(struct smsc_ircc_cb *self)
1802 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1803 iobase = self->io.sir_base;
1806 outb(0, iobase + UART_MCR);
1808 /* Turn off interrupts */
1809 outb(0, iobase + UART_IER);
1814 * Function smsc_sir_write_wakeup (self)
1816 * Called by the SIR interrupt handler when there's room for more data.
1817 * If we have more packets to send, we send them here.
1820 static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self)
1826 IRDA_ASSERT(self != NULL, return;);
1828 IRDA_DEBUG(4, "%s\n", __FUNCTION__);
1830 iobase = self->io.sir_base;
1832 /* Finished with frame? */
1833 if (self->tx_buff.len > 0) {
1834 /* Write data left in transmit buffer */
1835 actual = smsc_ircc_sir_write(iobase, self->io.fifo_size,
1836 self->tx_buff.data, self->tx_buff.len);
1837 self->tx_buff.data += actual;
1838 self->tx_buff.len -= actual;
1841 /*if (self->tx_buff.len ==0) {*/
1844 * Now serial buffer is almost free & we can start
1845 * transmission of another packet. But first we must check
1846 * if we need to change the speed of the hardware
1848 if (self->new_speed) {
1849 IRDA_DEBUG(5, "%s(), Changing speed to %d.\n",
1850 __FUNCTION__, self->new_speed);
1851 smsc_ircc_sir_wait_hw_transmitter_finish(self);
1852 smsc_ircc_change_speed(self, self->new_speed);
1853 self->new_speed = 0;
1855 /* Tell network layer that we want more frames */
1856 netif_wake_queue(self->netdev);
1858 self->stats.tx_packets++;
1860 if (self->io.speed <= 115200) {
1862 * Reset Rx FIFO to make sure that all reflected transmit data
1863 * is discarded. This is needed for half duplex operation
1865 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR;
1866 fcr |= self->io.speed < 38400 ?
1867 UART_FCR_TRIGGER_1 : UART_FCR_TRIGGER_14;
1869 outb(fcr, iobase + UART_FCR);
1871 /* Turn on receive interrupts */
1872 outb(UART_IER_RDI, iobase + UART_IER);
1878 * Function smsc_ircc_sir_write (iobase, fifo_size, buf, len)
1880 * Fill Tx FIFO with transmit data
1883 static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len)
1887 /* Tx FIFO should be empty! */
1888 if (!(inb(iobase + UART_LSR) & UART_LSR_THRE)) {
1889 IRDA_WARNING("%s(), failed, fifo not empty!\n", __FUNCTION__);
1893 /* Fill FIFO with current frame */
1894 while (fifo_size-- > 0 && actual < len) {
1895 /* Transmit next byte */
1896 outb(buf[actual], iobase + UART_TX);
1903 * Function smsc_ircc_is_receiving (self)
1905 * Returns true is we are currently receiving data
1908 static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self)
1910 return (self->rx_buff.state != OUTSIDE_FRAME);
1915 * Function smsc_ircc_probe_transceiver(self)
1917 * Tries to find the used Transceiver
1920 static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self)
1924 IRDA_ASSERT(self != NULL, return;);
1926 for (i = 0; smsc_transceivers[i].name != NULL; i++)
1927 if (smsc_transceivers[i].probe(self->io.fir_base)) {
1928 IRDA_MESSAGE(" %s transceiver found\n",
1929 smsc_transceivers[i].name);
1930 self->transceiver= i + 1;
1934 IRDA_MESSAGE("No transceiver found. Defaulting to %s\n",
1935 smsc_transceivers[SMSC_IRCC2_C_DEFAULT_TRANSCEIVER].name);
1937 self->transceiver = SMSC_IRCC2_C_DEFAULT_TRANSCEIVER;
1942 * Function smsc_ircc_set_transceiver_for_speed(self, speed)
1944 * Set the transceiver according to the speed
1947 static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed)
1951 trx = self->transceiver;
1953 smsc_transceivers[trx - 1].set_for_speed(self->io.fir_base, speed);
1957 * Function smsc_ircc_wait_hw_transmitter_finish ()
1959 * Wait for the real end of HW transmission
1961 * The UART is a strict FIFO, and we get called only when we have finished
1962 * pushing data to the FIFO, so the maximum amount of time we must wait
1963 * is only for the FIFO to drain out.
1965 * We use a simple calibrated loop. We may need to adjust the loop
1966 * delay (udelay) to balance I/O traffic and latency. And we also need to
1967 * adjust the maximum timeout.
1968 * It would probably be better to wait for the proper interrupt,
1969 * but it doesn't seem to be available.
1971 * We can't use jiffies or kernel timers because :
1972 * 1) We are called from the interrupt handler, which disable softirqs,
1973 * so jiffies won't be increased
1974 * 2) Jiffies granularity is usually very coarse (10ms), and we don't
1975 * want to wait that long to detect stuck hardware.
1979 static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self)
1981 int iobase = self->io.sir_base;
1982 int count = SMSC_IRCC2_HW_TRANSMITTER_TIMEOUT_US;
1984 /* Calibrated busy loop */
1985 while (count-- > 0 && !(inb(iobase + UART_LSR) & UART_LSR_TEMT))
1989 IRDA_DEBUG(0, "%s(): stuck transmitter\n", __FUNCTION__);
1998 static int __init smsc_ircc_look_for_chips(void)
2000 struct smsc_chip_address *address;
2002 unsigned int cfg_base, found;
2005 address = possible_addresses;
2007 while (address->cfg_base) {
2008 cfg_base = address->cfg_base;
2010 /*printk(KERN_WARNING "%s(): probing: 0x%02x for: 0x%02x\n", __FUNCTION__, cfg_base, address->type);*/
2012 if (address->type & SMSCSIO_TYPE_FDC) {
2014 if (address->type & SMSCSIO_TYPE_FLAT)
2015 if (!smsc_superio_flat(fdc_chips_flat, cfg_base, type))
2018 if (address->type & SMSCSIO_TYPE_PAGED)
2019 if (!smsc_superio_paged(fdc_chips_paged, cfg_base, type))
2022 if (address->type & SMSCSIO_TYPE_LPC) {
2024 if (address->type & SMSCSIO_TYPE_FLAT)
2025 if (!smsc_superio_flat(lpc_chips_flat, cfg_base, type))
2028 if (address->type & SMSCSIO_TYPE_PAGED)
2029 if (!smsc_superio_paged(lpc_chips_paged, cfg_base, type))
2038 * Function smsc_superio_flat (chip, base, type)
2040 * Try to get configuration of a smc SuperIO chip with flat register model
2043 static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfgbase, char *type)
2045 unsigned short firbase, sirbase;
2049 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2051 if (smsc_ircc_probe(cfgbase, SMSCSIOFLAT_DEVICEID_REG, chips, type) == NULL)
2054 outb(SMSCSIOFLAT_UARTMODE0C_REG, cfgbase);
2055 mode = inb(cfgbase + 1);
2057 /*printk(KERN_WARNING "%s(): mode: 0x%02x\n", __FUNCTION__, mode);*/
2059 if (!(mode & SMSCSIOFLAT_UART2MODE_VAL_IRDA))
2060 IRDA_WARNING("%s(): IrDA not enabled\n", __FUNCTION__);
2062 outb(SMSCSIOFLAT_UART2BASEADDR_REG, cfgbase);
2063 sirbase = inb(cfgbase + 1) << 2;
2066 outb(SMSCSIOFLAT_FIRBASEADDR_REG, cfgbase);
2067 firbase = inb(cfgbase + 1) << 3;
2070 outb(SMSCSIOFLAT_FIRDMASELECT_REG, cfgbase);
2071 dma = inb(cfgbase + 1) & SMSCSIOFLAT_FIRDMASELECT_MASK;
2074 outb(SMSCSIOFLAT_UARTIRQSELECT_REG, cfgbase);
2075 irq = inb(cfgbase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK;
2077 IRDA_MESSAGE("%s(): fir: 0x%02x, sir: 0x%02x, dma: %02d, irq: %d, mode: 0x%02x\n", __FUNCTION__, firbase, sirbase, dma, irq, mode);
2079 if (firbase && smsc_ircc_open(firbase, sirbase, dma, irq) == 0)
2082 /* Exit configuration */
2083 outb(SMSCSIO_CFGEXITKEY, cfgbase);
2089 * Function smsc_superio_paged (chip, base, type)
2091 * Try to get configuration of a smc SuperIO chip with paged register model
2094 static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type)
2096 unsigned short fir_io, sir_io;
2099 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2101 if (smsc_ircc_probe(cfg_base, 0x20, chips, type) == NULL)
2104 /* Select logical device (UART2) */
2105 outb(0x07, cfg_base);
2106 outb(0x05, cfg_base + 1);
2109 outb(0x60, cfg_base);
2110 sir_io = inb(cfg_base + 1) << 8;
2111 outb(0x61, cfg_base);
2112 sir_io |= inb(cfg_base + 1);
2115 outb(0x62, cfg_base);
2116 fir_io = inb(cfg_base + 1) << 8;
2117 outb(0x63, cfg_base);
2118 fir_io |= inb(cfg_base + 1);
2119 outb(0x2b, cfg_base); /* ??? */
2121 if (fir_io && smsc_ircc_open(fir_io, sir_io, ircc_dma, ircc_irq) == 0)
2124 /* Exit configuration */
2125 outb(SMSCSIO_CFGEXITKEY, cfg_base);
2131 static int __init smsc_access(unsigned short cfg_base, unsigned char reg)
2133 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2135 outb(reg, cfg_base);
2136 return inb(cfg_base) != reg ? -1 : 0;
2139 static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type)
2141 u8 devid, xdevid, rev;
2143 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2145 /* Leave configuration */
2147 outb(SMSCSIO_CFGEXITKEY, cfg_base);
2149 if (inb(cfg_base) == SMSCSIO_CFGEXITKEY) /* not a smc superio chip */
2152 outb(reg, cfg_base);
2154 xdevid = inb(cfg_base + 1);
2156 /* Enter configuration */
2158 outb(SMSCSIO_CFGACCESSKEY, cfg_base);
2161 if (smsc_access(cfg_base,0x55)) /* send second key and check */
2165 /* probe device ID */
2167 if (smsc_access(cfg_base, reg))
2170 devid = inb(cfg_base + 1);
2172 if (devid == 0 || devid == 0xff) /* typical values for unused port */
2175 /* probe revision ID */
2177 if (smsc_access(cfg_base, reg + 1))
2180 rev = inb(cfg_base + 1);
2182 if (rev >= 128) /* i think this will make no sense */
2185 if (devid == xdevid) /* protection against false positives */
2188 /* Check for expected device ID; are there others? */
2190 while (chip->devid != devid) {
2194 if (chip->name == NULL)
2198 IRDA_MESSAGE("found SMC SuperIO Chip (devid=0x%02x rev=%02X base=0x%04x): %s%s\n",
2199 devid, rev, cfg_base, type, chip->name);
2201 if (chip->rev > rev) {
2202 IRDA_MESSAGE("Revision higher than expected\n");
2206 if (chip->flags & NoIRDA)
2207 IRDA_MESSAGE("chipset does not support IRDA\n");
2212 static int __init smsc_superio_fdc(unsigned short cfg_base)
2216 if (!request_region(cfg_base, 2, driver_name)) {
2217 IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n",
2218 __FUNCTION__, cfg_base);
2220 if (!smsc_superio_flat(fdc_chips_flat, cfg_base, "FDC") ||
2221 !smsc_superio_paged(fdc_chips_paged, cfg_base, "FDC"))
2224 release_region(cfg_base, 2);
2230 static int __init smsc_superio_lpc(unsigned short cfg_base)
2234 if (!request_region(cfg_base, 2, driver_name)) {
2235 IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n",
2236 __FUNCTION__, cfg_base);
2238 if (!smsc_superio_flat(lpc_chips_flat, cfg_base, "LPC") ||
2239 !smsc_superio_paged(lpc_chips_paged, cfg_base, "LPC"))
2242 release_region(cfg_base, 2);
2247 /************************************************
2249 * Transceivers specific functions
2251 ************************************************/
2255 * Function smsc_ircc_set_transceiver_smsc_ircc_atc(fir_base, speed)
2257 * Program transceiver through smsc-ircc ATC circuitry
2261 static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed)
2263 unsigned long jiffies_now, jiffies_timeout;
2266 jiffies_now = jiffies;
2267 jiffies_timeout = jiffies + SMSC_IRCC2_ATC_PROGRAMMING_TIMEOUT_JIFFIES;
2270 register_bank(fir_base, 4);
2271 outb((inb(fir_base + IRCC_ATC) & IRCC_ATC_MASK) | IRCC_ATC_nPROGREADY|IRCC_ATC_ENABLE,
2272 fir_base + IRCC_ATC);
2274 while ((val = (inb(fir_base + IRCC_ATC) & IRCC_ATC_nPROGREADY)) &&
2275 !time_after(jiffies, jiffies_timeout))
2279 IRDA_WARNING("%s(): ATC: 0x%02x\n", __FUNCTION__,
2280 inb(fir_base + IRCC_ATC));
2284 * Function smsc_ircc_probe_transceiver_smsc_ircc_atc(fir_base)
2286 * Probe transceiver smsc-ircc ATC circuitry
2290 static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base)
2296 * Function smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(self, speed)
2302 static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed)
2313 fast_mode = IRCC_LCR_A_FAST;
2316 register_bank(fir_base, 0);
2317 outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast_mode, fir_base + IRCC_LCR_A);
2321 * Function smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(fir_base)
2327 static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base)
2333 * Function smsc_ircc_set_transceiver_toshiba_sat1800(fir_base, speed)
2339 static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed)
2350 fast_mode = /*IRCC_LCR_A_FAST |*/ IRCC_LCR_A_GP_DATA;
2354 /* This causes an interrupt */
2355 register_bank(fir_base, 0);
2356 outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast_mode, fir_base + IRCC_LCR_A);
2360 * Function smsc_ircc_probe_transceiver_toshiba_sat1800(fir_base)
2366 static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base)
2372 module_init(smsc_ircc_init);
2373 module_exit(smsc_ircc_cleanup);