1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45#include <linux/module.h>
46#include <linux/kernel.h>
47#include <linux/types.h>
48#include <linux/skbuff.h>
49#include <linux/netdevice.h>
50#include <linux/ioport.h>
51#include <linux/delay.h>
52#include <linux/slab.h>
53#include <linux/init.h>
54#include <linux/rtnetlink.h>
55#include <linux/serial_reg.h>
56#include <linux/dma-mapping.h>
57#include <linux/pnp.h>
58#include <linux/platform_device.h>
59
60#include <asm/io.h>
61#include <asm/dma.h>
62#include <asm/byteorder.h>
63
64#include <linux/spinlock.h>
65#include <linux/pm.h>
66#ifdef CONFIG_PCI
67#include <linux/pci.h>
68#endif
69
70#include <net/irda/wrapper.h>
71#include <net/irda/irda.h>
72#include <net/irda/irda_device.h>
73
74#include "smsc-ircc2.h"
75#include "smsc-sio.h"
76
77
78MODULE_AUTHOR("Daniele Peri <peri@csai.unipa.it>");
79MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver");
80MODULE_LICENSE("GPL");
81
82static int smsc_nopnp = 1;
83module_param_named(nopnp, smsc_nopnp, bool, 0);
84MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings, defaults to true");
85
86#define DMA_INVAL 255
87static int ircc_dma = DMA_INVAL;
88module_param(ircc_dma, int, 0);
89MODULE_PARM_DESC(ircc_dma, "DMA channel");
90
91#define IRQ_INVAL 255
92static int ircc_irq = IRQ_INVAL;
93module_param(ircc_irq, int, 0);
94MODULE_PARM_DESC(ircc_irq, "IRQ line");
95
96static int ircc_fir;
97module_param(ircc_fir, int, 0);
98MODULE_PARM_DESC(ircc_fir, "FIR Base Address");
99
100static int ircc_sir;
101module_param(ircc_sir, int, 0);
102MODULE_PARM_DESC(ircc_sir, "SIR Base Address");
103
104static int ircc_cfg;
105module_param(ircc_cfg, int, 0);
106MODULE_PARM_DESC(ircc_cfg, "Configuration register base address");
107
108static int ircc_transceiver;
109module_param(ircc_transceiver, int, 0);
110MODULE_PARM_DESC(ircc_transceiver, "Transceiver type");
111
112
113
114#ifdef CONFIG_PCI
115struct smsc_ircc_subsystem_configuration {
116 unsigned short vendor;
117 unsigned short device;
118 unsigned short subvendor;
119 unsigned short subdevice;
120 unsigned short sir_io;
121 unsigned short fir_io;
122 unsigned char fir_irq;
123 unsigned char fir_dma;
124 unsigned short cfg_base;
125 int (*preconfigure)(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);
126 const char *name;
127};
128#endif
129
130struct smsc_transceiver {
131 char *name;
132 void (*set_for_speed)(int fir_base, u32 speed);
133 int (*probe)(int fir_base);
134};
135
136struct smsc_chip {
137 char *name;
138 #if 0
139 u8 type;
140 #endif
141 u16 flags;
142 u8 devid;
143 u8 rev;
144};
145
146struct smsc_chip_address {
147 unsigned int cfg_base;
148 unsigned int type;
149};
150
151
152struct smsc_ircc_cb {
153 struct net_device *netdev;
154 struct net_device_stats stats;
155 struct irlap_cb *irlap;
156
157 chipio_t io;
158 iobuff_t tx_buff;
159 iobuff_t rx_buff;
160 dma_addr_t tx_buff_dma;
161 dma_addr_t rx_buff_dma;
162
163 struct qos_info qos;
164
165 spinlock_t lock;
166
167 __u32 new_speed;
168 __u32 flags;
169
170 int tx_buff_offsets[10];
171 int tx_len;
172
173 int transceiver;
174 struct platform_device *pldev;
175};
176
177
178
179#define SMSC_IRCC2_DRIVER_NAME "smsc-ircc2"
180
181#define SMSC_IRCC2_C_IRDA_FALLBACK_SPEED 9600
182#define SMSC_IRCC2_C_DEFAULT_TRANSCEIVER 1
183#define SMSC_IRCC2_C_NET_TIMEOUT 0
184#define SMSC_IRCC2_C_SIR_STOP 0
185
186static const char *driver_name = SMSC_IRCC2_DRIVER_NAME;
187
188
189
190static int smsc_ircc_open(unsigned int firbase, unsigned int sirbase, u8 dma, u8 irq);
191static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base);
192static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq);
193static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self);
194static void smsc_ircc_init_chip(struct smsc_ircc_cb *self);
195static int __exit smsc_ircc_close(struct smsc_ircc_cb *self);
196static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self);
197static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self);
198static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self);
199static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev);
200static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev);
201static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs);
202static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self);
203static void smsc_ircc_change_speed(struct smsc_ircc_cb *self, u32 speed);
204static void smsc_ircc_set_sir_speed(struct smsc_ircc_cb *self, u32 speed);
205static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id);
206static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev);
207static void smsc_ircc_sir_start(struct smsc_ircc_cb *self);
208#if SMSC_IRCC2_C_SIR_STOP
209static void smsc_ircc_sir_stop(struct smsc_ircc_cb *self);
210#endif
211static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self);
212static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len);
213static int smsc_ircc_net_open(struct net_device *dev);
214static int smsc_ircc_net_close(struct net_device *dev);
215static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
216#if SMSC_IRCC2_C_NET_TIMEOUT
217static void smsc_ircc_timeout(struct net_device *dev);
218#endif
219static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev);
220static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self);
221static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self);
222static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed);
223static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self);
224
225
226static int __init smsc_ircc_look_for_chips(void);
227static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type);
228static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
229static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
230static int __init smsc_superio_fdc(unsigned short cfg_base);
231static int __init smsc_superio_lpc(unsigned short cfg_base);
232#ifdef CONFIG_PCI
233static int __init preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf);
234static int __init preconfigure_through_82801(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);
235static void __init preconfigure_ali_port(struct pci_dev *dev,
236 unsigned short port);
237static int __init preconfigure_through_ali(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);
238static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,
239 unsigned short ircc_fir,
240 unsigned short ircc_sir,
241 unsigned char ircc_dma,
242 unsigned char ircc_irq);
243#endif
244
245
246
247static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed);
248static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base);
249static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed);
250static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base);
251static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed);
252static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base);
253
254
255
256static int smsc_ircc_suspend(struct platform_device *dev, pm_message_t state);
257static int smsc_ircc_resume(struct platform_device *dev);
258
259static struct platform_driver smsc_ircc_driver = {
260 .suspend = smsc_ircc_suspend,
261 .resume = smsc_ircc_resume,
262 .driver = {
263 .name = SMSC_IRCC2_DRIVER_NAME,
264 },
265};
266
267
268
269static struct smsc_transceiver smsc_transceivers[] =
270{
271 { "Toshiba Satellite 1800 (GP data pin select)", smsc_ircc_set_transceiver_toshiba_sat1800, smsc_ircc_probe_transceiver_toshiba_sat1800 },
272 { "Fast pin select", smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select, smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select },
273 { "ATC IRMode", smsc_ircc_set_transceiver_smsc_ircc_atc, smsc_ircc_probe_transceiver_smsc_ircc_atc },
274 { NULL, NULL }
275};
276#define SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS (ARRAY_SIZE(smsc_transceivers) - 1)
277
278
279
280#define KEY55_1 0
281#define KEY55_2 1
282#define NoIRDA 2
283#define SIR 0
284#define FIR 4
285#define SERx4 8
286
287static struct smsc_chip __initdata fdc_chips_flat[] =
288{
289
290 { "37C44", KEY55_1|NoIRDA, 0x00, 0x00 },
291 { "37C665GT", KEY55_2|NoIRDA, 0x65, 0x01 },
292 { "37C665GT", KEY55_2|NoIRDA, 0x66, 0x01 },
293 { "37C669", KEY55_2|SIR|SERx4, 0x03, 0x02 },
294 { "37C669", KEY55_2|SIR|SERx4, 0x04, 0x02 },
295 { "37C78", KEY55_2|NoIRDA, 0x78, 0x00 },
296 { "37N769", KEY55_1|FIR|SERx4, 0x28, 0x00 },
297 { "37N869", KEY55_1|FIR|SERx4, 0x29, 0x00 },
298 { NULL }
299};
300
301static struct smsc_chip __initdata fdc_chips_paged[] =
302{
303
304 { "37B72X", KEY55_1|SIR|SERx4, 0x4c, 0x00 },
305 { "37B77X", KEY55_1|SIR|SERx4, 0x43, 0x00 },
306 { "37B78X", KEY55_1|SIR|SERx4, 0x44, 0x00 },
307 { "37B80X", KEY55_1|SIR|SERx4, 0x42, 0x00 },
308 { "37C67X", KEY55_1|FIR|SERx4, 0x40, 0x00 },
309 { "37C93X", KEY55_2|SIR|SERx4, 0x02, 0x01 },
310 { "37C93XAPM", KEY55_1|SIR|SERx4, 0x30, 0x01 },
311 { "37C93XFR", KEY55_2|FIR|SERx4, 0x03, 0x01 },
312 { "37M707", KEY55_1|SIR|SERx4, 0x42, 0x00 },
313 { "37M81X", KEY55_1|SIR|SERx4, 0x4d, 0x00 },
314 { "37N958FR", KEY55_1|FIR|SERx4, 0x09, 0x04 },
315 { "37N971", KEY55_1|FIR|SERx4, 0x0a, 0x00 },
316 { "37N972", KEY55_1|FIR|SERx4, 0x0b, 0x00 },
317 { NULL }
318};
319
320static struct smsc_chip __initdata lpc_chips_flat[] =
321{
322
323 { "47N227", KEY55_1|FIR|SERx4, 0x5a, 0x00 },
324 { "47N227", KEY55_1|FIR|SERx4, 0x7a, 0x00 },
325 { "47N267", KEY55_1|FIR|SERx4, 0x5e, 0x00 },
326 { NULL }
327};
328
329static struct smsc_chip __initdata lpc_chips_paged[] =
330{
331
332 { "47B27X", KEY55_1|SIR|SERx4, 0x51, 0x00 },
333 { "47B37X", KEY55_1|SIR|SERx4, 0x52, 0x00 },
334 { "47M10X", KEY55_1|SIR|SERx4, 0x59, 0x00 },
335 { "47M120", KEY55_1|NoIRDA|SERx4, 0x5c, 0x00 },
336 { "47M13X", KEY55_1|SIR|SERx4, 0x59, 0x00 },
337 { "47M14X", KEY55_1|SIR|SERx4, 0x5f, 0x00 },
338 { "47N252", KEY55_1|FIR|SERx4, 0x0e, 0x00 },
339 { "47S42X", KEY55_1|SIR|SERx4, 0x57, 0x00 },
340 { NULL }
341};
342
343#define SMSCSIO_TYPE_FDC 1
344#define SMSCSIO_TYPE_LPC 2
345#define SMSCSIO_TYPE_FLAT 4
346#define SMSCSIO_TYPE_PAGED 8
347
348static struct smsc_chip_address __initdata possible_addresses[] =
349{
350 { 0x3f0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
351 { 0x370, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
352 { 0xe0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
353 { 0x2e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
354 { 0x4e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED },
355 { 0, 0 }
356};
357
358
359
360static struct smsc_ircc_cb *dev_self[] = { NULL, NULL };
361static unsigned short dev_count;
362
363static inline void register_bank(int iobase, int bank)
364{
365 outb(((inb(iobase + IRCC_MASTER) & 0xf0) | (bank & 0x07)),
366 iobase + IRCC_MASTER);
367}
368
369
370static const struct pnp_device_id smsc_ircc_pnp_table[] = {
371 { .id = "SMCf010", .driver_data = 0 },
372
373 { }
374};
375MODULE_DEVICE_TABLE(pnp, smsc_ircc_pnp_table);
376
377static int pnp_driver_registered;
378
379static int __init smsc_ircc_pnp_probe(struct pnp_dev *dev,
380 const struct pnp_device_id *dev_id)
381{
382 unsigned int firbase, sirbase;
383 u8 dma, irq;
384
385 if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) &&
386 pnp_dma_valid(dev, 0) && pnp_irq_valid(dev, 0)))
387 return -EINVAL;
388
389 sirbase = pnp_port_start(dev, 0);
390 firbase = pnp_port_start(dev, 1);
391 dma = pnp_dma(dev, 0);
392 irq = pnp_irq(dev, 0);
393
394 if (smsc_ircc_open(firbase, sirbase, dma, irq))
395 return -ENODEV;
396
397 return 0;
398}
399
400static struct pnp_driver smsc_ircc_pnp_driver = {
401 .name = "smsc-ircc2",
402 .id_table = smsc_ircc_pnp_table,
403 .probe = smsc_ircc_pnp_probe,
404};
405
406
407
408
409
410
411
412
413
414
415static int __init smsc_ircc_legacy_probe(void)
416{
417 int ret = 0;
418
419#ifdef CONFIG_PCI
420 if (smsc_ircc_preconfigure_subsystems(ircc_cfg, ircc_fir, ircc_sir, ircc_dma, ircc_irq) < 0) {
421
422 IRDA_ERROR("%s, Preconfiguration failed !\n", driver_name);
423 }
424#endif
425
426 if (ircc_fir > 0 && ircc_sir > 0) {
427 IRDA_MESSAGE(" Overriding FIR address 0x%04x\n", ircc_fir);
428 IRDA_MESSAGE(" Overriding SIR address 0x%04x\n", ircc_sir);
429
430 if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq))
431 ret = -ENODEV;
432 } else {
433 ret = -ENODEV;
434
435
436 if (ircc_cfg > 0) {
437 IRDA_MESSAGE(" Overriding configuration address "
438 "0x%04x\n", ircc_cfg);
439 if (!smsc_superio_fdc(ircc_cfg))
440 ret = 0;
441 if (!smsc_superio_lpc(ircc_cfg))
442 ret = 0;
443 }
444
445 if (smsc_ircc_look_for_chips() > 0)
446 ret = 0;
447 }
448 return ret;
449}
450
451
452
453
454
455
456
457static int __init smsc_ircc_init(void)
458{
459 int ret;
460
461 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
462
463 ret = platform_driver_register(&smsc_ircc_driver);
464 if (ret) {
465 IRDA_ERROR("%s, Can't register driver!\n", driver_name);
466 return ret;
467 }
468
469 dev_count = 0;
470
471 if (smsc_nopnp || !pnp_platform_devices ||
472 ircc_cfg || ircc_fir || ircc_sir ||
473 ircc_dma != DMA_INVAL || ircc_irq != IRQ_INVAL) {
474 ret = smsc_ircc_legacy_probe();
475 } else {
476 if (pnp_register_driver(&smsc_ircc_pnp_driver) == 0)
477 pnp_driver_registered = 1;
478 }
479
480 if (ret) {
481 if (pnp_driver_registered)
482 pnp_unregister_driver(&smsc_ircc_pnp_driver);
483 platform_driver_unregister(&smsc_ircc_driver);
484 }
485
486 return ret;
487}
488
489
490
491
492
493
494
495static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
496{
497 struct smsc_ircc_cb *self;
498 struct net_device *dev;
499 int err;
500
501 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
502
503 err = smsc_ircc_present(fir_base, sir_base);
504 if (err)
505 goto err_out;
506
507 err = -ENOMEM;
508 if (dev_count >= ARRAY_SIZE(dev_self)) {
509 IRDA_WARNING("%s(), too many devices!\n", __FUNCTION__);
510 goto err_out1;
511 }
512
513
514
515
516 dev = alloc_irdadev(sizeof(struct smsc_ircc_cb));
517 if (!dev) {
518 IRDA_WARNING("%s() can't allocate net device\n", __FUNCTION__);
519 goto err_out1;
520 }
521
522 dev->hard_start_xmit = smsc_ircc_hard_xmit_sir;
523#if SMSC_IRCC2_C_NET_TIMEOUT
524 dev->tx_timeout = smsc_ircc_timeout;
525 dev->watchdog_timeo = HZ * 2;
526#endif
527 dev->open = smsc_ircc_net_open;
528 dev->stop = smsc_ircc_net_close;
529 dev->do_ioctl = smsc_ircc_net_ioctl;
530 dev->get_stats = smsc_ircc_net_get_stats;
531
532 self = netdev_priv(dev);
533 self->netdev = dev;
534
535
536 dev->base_addr = self->io.fir_base = fir_base;
537 dev->irq = self->io.irq = irq;
538
539
540 dev_self[dev_count] = self;
541 spin_lock_init(&self->lock);
542
543 self->rx_buff.truesize = SMSC_IRCC2_RX_BUFF_TRUESIZE;
544 self->tx_buff.truesize = SMSC_IRCC2_TX_BUFF_TRUESIZE;
545
546 self->rx_buff.head =
547 dma_alloc_coherent(NULL, self->rx_buff.truesize,
548 &self->rx_buff_dma, GFP_KERNEL);
549 if (self->rx_buff.head == NULL) {
550 IRDA_ERROR("%s, Can't allocate memory for receive buffer!\n",
551 driver_name);
552 goto err_out2;
553 }
554
555 self->tx_buff.head =
556 dma_alloc_coherent(NULL, self->tx_buff.truesize,
557 &self->tx_buff_dma, GFP_KERNEL);
558 if (self->tx_buff.head == NULL) {
559 IRDA_ERROR("%s, Can't allocate memory for transmit buffer!\n",
560 driver_name);
561 goto err_out3;
562 }
563
564 memset(self->rx_buff.head, 0, self->rx_buff.truesize);
565 memset(self->tx_buff.head, 0, self->tx_buff.truesize);
566
567 self->rx_buff.in_frame = FALSE;
568 self->rx_buff.state = OUTSIDE_FRAME;
569 self->tx_buff.data = self->tx_buff.head;
570 self->rx_buff.data = self->rx_buff.head;
571
572 smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq);
573 smsc_ircc_setup_qos(self);
574 smsc_ircc_init_chip(self);
575
576 if (ircc_transceiver > 0 &&
577 ircc_transceiver < SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS)
578 self->transceiver = ircc_transceiver;
579 else
580 smsc_ircc_probe_transceiver(self);
581
582 err = register_netdev(self->netdev);
583 if (err) {
584 IRDA_ERROR("%s, Network device registration failed!\n",
585 driver_name);
586 goto err_out4;
587 }
588
589 self->pldev = platform_device_register_simple(SMSC_IRCC2_DRIVER_NAME,
590 dev_count, NULL, 0);
591 if (IS_ERR(self->pldev)) {
592 err = PTR_ERR(self->pldev);
593 goto err_out5;
594 }
595 platform_set_drvdata(self->pldev, self);
596
597 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
598 dev_count++;
599
600 return 0;
601
602 err_out5:
603 unregister_netdev(self->netdev);
604
605 err_out4:
606 dma_free_coherent(NULL, self->tx_buff.truesize,
607 self->tx_buff.head, self->tx_buff_dma);
608 err_out3:
609 dma_free_coherent(NULL, self->rx_buff.truesize,
610 self->rx_buff.head, self->rx_buff_dma);
611 err_out2:
612 free_netdev(self->netdev);
613 dev_self[dev_count] = NULL;
614 err_out1:
615 release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
616 release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
617 err_out:
618 return err;
619}
620
621
622
623
624
625
626
627static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base)
628{
629 unsigned char low, high, chip, config, dma, irq, version;
630
631 if (!request_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT,
632 driver_name)) {
633 IRDA_WARNING("%s: can't get fir_base of 0x%03x\n",
634 __FUNCTION__, fir_base);
635 goto out1;
636 }
637
638 if (!request_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT,
639 driver_name)) {
640 IRDA_WARNING("%s: can't get sir_base of 0x%03x\n",
641 __FUNCTION__, sir_base);
642 goto out2;
643 }
644
645 register_bank(fir_base, 3);
646
647 high = inb(fir_base + IRCC_ID_HIGH);
648 low = inb(fir_base + IRCC_ID_LOW);
649 chip = inb(fir_base + IRCC_CHIP_ID);
650 version = inb(fir_base + IRCC_VERSION);
651 config = inb(fir_base + IRCC_INTERFACE);
652 dma = config & IRCC_INTERFACE_DMA_MASK;
653 irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4;
654
655 if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) {
656 IRDA_WARNING("%s(), addr 0x%04x - no device found!\n",
657 __FUNCTION__, fir_base);
658 goto out3;
659 }
660 IRDA_MESSAGE("SMsC IrDA Controller found\n IrCC version %d.%d, "
661 "firport 0x%03x, sirport 0x%03x dma=%d, irq=%d\n",
662 chip & 0x0f, version, fir_base, sir_base, dma, irq);
663
664 return 0;
665
666 out3:
667 release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
668 out2:
669 release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
670 out1:
671 return -ENODEV;
672}
673
674
675
676
677
678
679
680static void smsc_ircc_setup_io(struct smsc_ircc_cb *self,
681 unsigned int fir_base, unsigned int sir_base,
682 u8 dma, u8 irq)
683{
684 unsigned char config, chip_dma, chip_irq;
685
686 register_bank(fir_base, 3);
687 config = inb(fir_base + IRCC_INTERFACE);
688 chip_dma = config & IRCC_INTERFACE_DMA_MASK;
689 chip_irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4;
690
691 self->io.fir_base = fir_base;
692 self->io.sir_base = sir_base;
693 self->io.fir_ext = SMSC_IRCC2_FIR_CHIP_IO_EXTENT;
694 self->io.sir_ext = SMSC_IRCC2_SIR_CHIP_IO_EXTENT;
695 self->io.fifo_size = SMSC_IRCC2_FIFO_SIZE;
696 self->io.speed = SMSC_IRCC2_C_IRDA_FALLBACK_SPEED;
697
698 if (irq != IRQ_INVAL) {
699 if (irq != chip_irq)
700 IRDA_MESSAGE("%s, Overriding IRQ - chip says %d, using %d\n",
701 driver_name, chip_irq, irq);
702 self->io.irq = irq;
703 } else
704 self->io.irq = chip_irq;
705
706 if (dma != DMA_INVAL) {
707 if (dma != chip_dma)
708 IRDA_MESSAGE("%s, Overriding DMA - chip says %d, using %d\n",
709 driver_name, chip_dma, dma);
710 self->io.dma = dma;
711 } else
712 self->io.dma = chip_dma;
713
714}
715
716
717
718
719
720
721
722static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self)
723{
724
725 irda_init_max_qos_capabilies(&self->qos);
726
727 self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|
728 IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8);
729
730 self->qos.min_turn_time.bits = SMSC_IRCC2_MIN_TURN_TIME;
731 self->qos.window_size.bits = SMSC_IRCC2_WINDOW_SIZE;
732 irda_qos_bits_to_value(&self->qos);
733}
734
735
736
737
738
739
740
741static void smsc_ircc_init_chip(struct smsc_ircc_cb *self)
742{
743 int iobase = self->io.fir_base;
744
745 register_bank(iobase, 0);
746 outb(IRCC_MASTER_RESET, iobase + IRCC_MASTER);
747 outb(0x00, iobase + IRCC_MASTER);
748
749 register_bank(iobase, 1);
750 outb(((inb(iobase + IRCC_SCE_CFGA) & 0x87) | IRCC_CFGA_IRDA_SIR_A),
751 iobase + IRCC_SCE_CFGA);
752
753#ifdef smsc_669
754 outb(((inb(iobase + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM),
755 iobase + IRCC_SCE_CFGB);
756#else
757 outb(((inb(iobase + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR),
758 iobase + IRCC_SCE_CFGB);
759#endif
760 (void) inb(iobase + IRCC_FIFO_THRESHOLD);
761 outb(SMSC_IRCC2_FIFO_THRESHOLD, iobase + IRCC_FIFO_THRESHOLD);
762
763 register_bank(iobase, 4);
764 outb((inb(iobase + IRCC_CONTROL) & 0x30), iobase + IRCC_CONTROL);
765
766 register_bank(iobase, 0);
767 outb(0, iobase + IRCC_LCR_A);
768
769 smsc_ircc_set_sir_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED);
770
771
772 outb(0x00, iobase + IRCC_MASTER);
773}
774
775
776
777
778
779
780
781static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
782{
783 struct if_irda_req *irq = (struct if_irda_req *) rq;
784 struct smsc_ircc_cb *self;
785 unsigned long flags;
786 int ret = 0;
787
788 IRDA_ASSERT(dev != NULL, return -1;);
789
790 self = netdev_priv(dev);
791
792 IRDA_ASSERT(self != NULL, return -1;);
793
794 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd);
795
796 switch (cmd) {
797 case SIOCSBANDWIDTH:
798 if (!capable(CAP_NET_ADMIN))
799 ret = -EPERM;
800 else {
801
802
803 spin_lock_irqsave(&self->lock, flags);
804 smsc_ircc_change_speed(self, irq->ifr_baudrate);
805 spin_unlock_irqrestore(&self->lock, flags);
806 }
807 break;
808 case SIOCSMEDIABUSY:
809 if (!capable(CAP_NET_ADMIN)) {
810 ret = -EPERM;
811 break;
812 }
813
814 irda_device_set_media_busy(self->netdev, TRUE);
815 break;
816 case SIOCGRECEIVING:
817 irq->ifr_receiving = smsc_ircc_is_receiving(self);
818 break;
819 #if 0
820 case SIOCSDTRRTS:
821 if (!capable(CAP_NET_ADMIN)) {
822 ret = -EPERM;
823 break;
824 }
825 smsc_ircc_sir_set_dtr_rts(dev, irq->ifr_dtr, irq->ifr_rts);
826 break;
827 #endif
828 default:
829 ret = -EOPNOTSUPP;
830 }
831
832 return ret;
833}
834
835static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev)
836{
837 struct smsc_ircc_cb *self = netdev_priv(dev);
838
839 return &self->stats;
840}
841
842#if SMSC_IRCC2_C_NET_TIMEOUT
843
844
845
846
847
848
849
850static void smsc_ircc_timeout(struct net_device *dev)
851{
852 struct smsc_ircc_cb *self = netdev_priv(dev);
853 unsigned long flags;
854
855 IRDA_WARNING("%s: transmit timed out, changing speed to: %d\n",
856 dev->name, self->io.speed);
857 spin_lock_irqsave(&self->lock, flags);
858 smsc_ircc_sir_start(self);
859 smsc_ircc_change_speed(self, self->io.speed);
860 dev->trans_start = jiffies;
861 netif_wake_queue(dev);
862 spin_unlock_irqrestore(&self->lock, flags);
863}
864#endif
865
866
867
868
869
870
871
872
873int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
874{
875 struct smsc_ircc_cb *self;
876 unsigned long flags;
877 s32 speed;
878
879 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
880
881 IRDA_ASSERT(dev != NULL, return 0;);
882
883 self = netdev_priv(dev);
884 IRDA_ASSERT(self != NULL, return 0;);
885
886 netif_stop_queue(dev);
887
888
889 spin_lock_irqsave(&self->lock, flags);
890
891
892 speed = irda_get_next_speed(skb);
893 if (speed != self->io.speed && speed != -1) {
894
895 if (!skb->len) {
896
897
898
899
900
901
902
903
904
905 smsc_ircc_sir_wait_hw_transmitter_finish(self);
906 smsc_ircc_change_speed(self, speed);
907 spin_unlock_irqrestore(&self->lock, flags);
908 dev_kfree_skb(skb);
909 return 0;
910 }
911 self->new_speed = speed;
912 }
913
914
915 self->tx_buff.data = self->tx_buff.head;
916
917
918 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
919 self->tx_buff.truesize);
920
921 self->stats.tx_bytes += self->tx_buff.len;
922
923
924 outb(UART_IER_THRI, self->io.sir_base + UART_IER);
925
926 spin_unlock_irqrestore(&self->lock, flags);
927
928 dev_kfree_skb(skb);
929
930 return 0;
931}
932
933
934
935
936
937
938
939static void smsc_ircc_set_fir_speed(struct smsc_ircc_cb *self, u32 speed)
940{
941 int fir_base, ir_mode, ctrl, fast;
942
943 IRDA_ASSERT(self != NULL, return;);
944 fir_base = self->io.fir_base;
945
946 self->io.speed = speed;
947
948 switch (speed) {
949 default:
950 case 576000:
951 ir_mode = IRCC_CFGA_IRDA_HDLC;
952 ctrl = IRCC_CRC;
953 fast = 0;
954 IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __FUNCTION__);
955 break;
956 case 1152000:
957 ir_mode = IRCC_CFGA_IRDA_HDLC;
958 ctrl = IRCC_1152 | IRCC_CRC;
959 fast = IRCC_LCR_A_FAST | IRCC_LCR_A_GP_DATA;
960 IRDA_DEBUG(0, "%s(), handling baud of 1152000\n",
961 __FUNCTION__);
962 break;
963 case 4000000:
964 ir_mode = IRCC_CFGA_IRDA_4PPM;
965 ctrl = IRCC_CRC;
966 fast = IRCC_LCR_A_FAST;
967 IRDA_DEBUG(0, "%s(), handling baud of 4000000\n",
968 __FUNCTION__);
969 break;
970 }
971 #if 0
972 Now in tranceiver!
973
974 register_bank(fir_base, 0);
975 outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast, fir_base + IRCC_LCR_A);
976 #endif
977
978 register_bank(fir_base, 1);
979 outb(((inb(fir_base + IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | ir_mode), fir_base + IRCC_SCE_CFGA);
980
981 register_bank(fir_base, 4);
982 outb((inb(fir_base + IRCC_CONTROL) & 0x30) | ctrl, fir_base + IRCC_CONTROL);
983}
984
985
986
987
988
989
990
991static void smsc_ircc_fir_start(struct smsc_ircc_cb *self)
992{
993 struct net_device *dev;
994 int fir_base;
995
996 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
997
998 IRDA_ASSERT(self != NULL, return;);
999 dev = self->netdev;
1000 IRDA_ASSERT(dev != NULL, return;);
1001
1002 fir_base = self->io.fir_base;
1003
1004
1005
1006
1007 dev->hard_start_xmit = smsc_ircc_hard_xmit_fir;
1008
1009
1010 outb(inb(fir_base + IRCC_LCR_A) | IRCC_LCR_A_FIFO_RESET, fir_base + IRCC_LCR_A);
1011
1012
1013
1014
1015 register_bank(fir_base, 1);
1016
1017
1018#ifdef SMSC_669
1019 outb(((inb(fir_base + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM),
1020 fir_base + IRCC_SCE_CFGB);
1021#else
1022 outb(((inb(fir_base + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR),
1023 fir_base + IRCC_SCE_CFGB);
1024#endif
1025 (void) inb(fir_base + IRCC_FIFO_THRESHOLD);
1026
1027
1028 outb(0, fir_base + IRCC_MASTER);
1029 register_bank(fir_base, 0);
1030 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, fir_base + IRCC_IER);
1031 outb(IRCC_MASTER_INT_EN, fir_base + IRCC_MASTER);
1032}
1033
1034
1035
1036
1037
1038
1039
1040static void smsc_ircc_fir_stop(struct smsc_ircc_cb *self)
1041{
1042 int fir_base;
1043
1044 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1045
1046 IRDA_ASSERT(self != NULL, return;);
1047
1048 fir_base = self->io.fir_base;
1049 register_bank(fir_base, 0);
1050
1051 outb(inb(fir_base + IRCC_LCR_B) & IRCC_LCR_B_SIP_ENABLE, fir_base + IRCC_LCR_B);
1052}
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063static void smsc_ircc_change_speed(struct smsc_ircc_cb *self, u32 speed)
1064{
1065 struct net_device *dev;
1066 int last_speed_was_sir;
1067
1068 IRDA_DEBUG(0, "%s() changing speed to: %d\n", __FUNCTION__, speed);
1069
1070 IRDA_ASSERT(self != NULL, return;);
1071 dev = self->netdev;
1072
1073 last_speed_was_sir = self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED;
1074
1075 #if 0
1076
1077 speed= 1152000;
1078 self->io.speed = speed;
1079 last_speed_was_sir = 0;
1080 smsc_ircc_fir_start(self);
1081 #endif
1082
1083 if (self->io.speed == 0)
1084 smsc_ircc_sir_start(self);
1085
1086 #if 0
1087 if (!last_speed_was_sir) speed = self->io.speed;
1088 #endif
1089
1090 if (self->io.speed != speed)
1091 smsc_ircc_set_transceiver_for_speed(self, speed);
1092
1093 self->io.speed = speed;
1094
1095 if (speed <= SMSC_IRCC2_MAX_SIR_SPEED) {
1096 if (!last_speed_was_sir) {
1097 smsc_ircc_fir_stop(self);
1098 smsc_ircc_sir_start(self);
1099 }
1100 smsc_ircc_set_sir_speed(self, speed);
1101 } else {
1102 if (last_speed_was_sir) {
1103 #if SMSC_IRCC2_C_SIR_STOP
1104 smsc_ircc_sir_stop(self);
1105 #endif
1106 smsc_ircc_fir_start(self);
1107 }
1108 smsc_ircc_set_fir_speed(self, speed);
1109
1110 #if 0
1111 self->tx_buff.len = 10;
1112 self->tx_buff.data = self->tx_buff.head;
1113
1114 smsc_ircc_dma_xmit(self, 4000);
1115 #endif
1116
1117 smsc_ircc_dma_receive(self);
1118 }
1119
1120 netif_wake_queue(dev);
1121}
1122
1123
1124
1125
1126
1127
1128
1129void smsc_ircc_set_sir_speed(struct smsc_ircc_cb *self, __u32 speed)
1130{
1131 int iobase;
1132 int fcr;
1133 int lcr;
1134 int divisor;
1135
1136 IRDA_DEBUG(0, "%s(), Setting speed to: %d\n", __FUNCTION__, speed);
1137
1138 IRDA_ASSERT(self != NULL, return;);
1139 iobase = self->io.sir_base;
1140
1141
1142 self->io.speed = speed;
1143
1144
1145 outb(0, iobase + UART_IER);
1146
1147 divisor = SMSC_IRCC2_MAX_SIR_SPEED / speed;
1148
1149 fcr = UART_FCR_ENABLE_FIFO;
1150
1151
1152
1153
1154
1155
1156 fcr |= self->io.speed < 38400 ?
1157 UART_FCR_TRIGGER_1 : UART_FCR_TRIGGER_14;
1158
1159
1160 lcr = UART_LCR_WLEN8;
1161
1162 outb(UART_LCR_DLAB | lcr, iobase + UART_LCR);
1163 outb(divisor & 0xff, iobase + UART_DLL);
1164 outb(divisor >> 8, iobase + UART_DLM);
1165 outb(lcr, iobase + UART_LCR);
1166 outb(fcr, iobase + UART_FCR);
1167
1168
1169 outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER);
1170
1171 IRDA_DEBUG(2, "%s() speed changed to: %d\n", __FUNCTION__, speed);
1172}
1173
1174
1175
1176
1177
1178
1179
1180
1181static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev)
1182{
1183 struct smsc_ircc_cb *self;
1184 unsigned long flags;
1185 s32 speed;
1186 int mtt;
1187
1188 IRDA_ASSERT(dev != NULL, return 0;);
1189 self = netdev_priv(dev);
1190 IRDA_ASSERT(self != NULL, return 0;);
1191
1192 netif_stop_queue(dev);
1193
1194
1195 spin_lock_irqsave(&self->lock, flags);
1196
1197
1198 speed = irda_get_next_speed(skb);
1199 if (speed != self->io.speed && speed != -1) {
1200
1201 if (!skb->len) {
1202
1203
1204
1205 smsc_ircc_change_speed(self, speed);
1206 spin_unlock_irqrestore(&self->lock, flags);
1207 dev_kfree_skb(skb);
1208 return 0;
1209 }
1210
1211 self->new_speed = speed;
1212 }
1213
1214 skb_copy_from_linear_data(skb, self->tx_buff.head, skb->len);
1215
1216 self->tx_buff.len = skb->len;
1217 self->tx_buff.data = self->tx_buff.head;
1218
1219 mtt = irda_get_mtt(skb);
1220 if (mtt) {
1221 int bofs;
1222
1223
1224
1225
1226
1227 bofs = mtt * (self->io.speed / 1000) / 8000;
1228 if (bofs > 4095)
1229 bofs = 4095;
1230
1231 smsc_ircc_dma_xmit(self, bofs);
1232 } else {
1233
1234 smsc_ircc_dma_xmit(self, 0);
1235 }
1236
1237 spin_unlock_irqrestore(&self->lock, flags);
1238 dev_kfree_skb(skb);
1239
1240 return 0;
1241}
1242
1243
1244
1245
1246
1247
1248
1249static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs)
1250{
1251 int iobase = self->io.fir_base;
1252 u8 ctrl;
1253
1254 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1255#if 1
1256
1257 register_bank(iobase, 0);
1258 outb(0x00, iobase + IRCC_LCR_B);
1259#endif
1260 register_bank(iobase, 1);
1261 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1262 iobase + IRCC_SCE_CFGB);
1263
1264 self->io.direction = IO_XMIT;
1265
1266
1267 register_bank(iobase, 4);
1268 outb(bofs & 0xff, iobase + IRCC_BOF_COUNT_LO);
1269 ctrl = inb(iobase + IRCC_CONTROL) & 0xf0;
1270 outb(ctrl | ((bofs >> 8) & 0x0f), iobase + IRCC_BOF_COUNT_HI);
1271
1272
1273 outb(self->tx_buff.len >> 8, iobase + IRCC_TX_SIZE_HI);
1274 outb(self->tx_buff.len & 0xff, iobase + IRCC_TX_SIZE_LO);
1275
1276
1277
1278
1279 register_bank(iobase, 1);
1280 outb(inb(iobase + IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE |
1281 IRCC_CFGB_DMA_BURST, iobase + IRCC_SCE_CFGB);
1282
1283
1284 irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
1285 DMA_TX_MODE);
1286
1287
1288
1289 register_bank(iobase, 0);
1290 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
1291 outb(IRCC_MASTER_INT_EN, iobase + IRCC_MASTER);
1292
1293
1294 outb(IRCC_LCR_B_SCE_TRANSMIT | IRCC_LCR_B_SIP_ENABLE, iobase + IRCC_LCR_B);
1295}
1296
1297
1298
1299
1300
1301
1302
1303
1304static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self)
1305{
1306 int iobase = self->io.fir_base;
1307
1308 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1309#if 0
1310
1311 register_bank(iobase, 0);
1312 outb(0x00, iobase + IRCC_LCR_B);
1313#endif
1314 register_bank(iobase, 1);
1315 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1316 iobase + IRCC_SCE_CFGB);
1317
1318
1319 register_bank(iobase, 0);
1320 if (inb(iobase + IRCC_LSR) & IRCC_LSR_UNDERRUN) {
1321 self->stats.tx_errors++;
1322 self->stats.tx_fifo_errors++;
1323
1324
1325 register_bank(iobase, 0);
1326 outb(IRCC_MASTER_ERROR_RESET, iobase + IRCC_MASTER);
1327 outb(0x00, iobase + IRCC_MASTER);
1328 } else {
1329 self->stats.tx_packets++;
1330 self->stats.tx_bytes += self->tx_buff.len;
1331 }
1332
1333
1334 if (self->new_speed) {
1335 smsc_ircc_change_speed(self, self->new_speed);
1336 self->new_speed = 0;
1337 }
1338
1339 netif_wake_queue(self->netdev);
1340}
1341
1342
1343
1344
1345
1346
1347
1348
1349static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self)
1350{
1351 int iobase = self->io.fir_base;
1352#if 0
1353
1354 register_bank(iobase, 1);
1355 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1356 iobase + IRCC_SCE_CFGB);
1357#endif
1358
1359
1360 register_bank(iobase, 0);
1361 outb(0x00, iobase + IRCC_LCR_B);
1362
1363
1364 register_bank(iobase, 1);
1365 outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE,
1366 iobase + IRCC_SCE_CFGB);
1367
1368 self->io.direction = IO_RECV;
1369 self->rx_buff.data = self->rx_buff.head;
1370
1371
1372 register_bank(iobase, 4);
1373 outb((2050 >> 8) & 0x0f, iobase + IRCC_RX_SIZE_HI);
1374 outb(2050 & 0xff, iobase + IRCC_RX_SIZE_LO);
1375
1376
1377 irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
1378 DMA_RX_MODE);
1379
1380
1381 register_bank(iobase, 1);
1382 outb(inb(iobase + IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE |
1383 IRCC_CFGB_DMA_BURST, iobase + IRCC_SCE_CFGB);
1384
1385
1386 register_bank(iobase, 0);
1387 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
1388 outb(IRCC_MASTER_INT_EN, iobase + IRCC_MASTER);
1389
1390
1391 register_bank(iobase, 0);
1392 outb(IRCC_LCR_B_SCE_RECEIVE | IRCC_LCR_B_SIP_ENABLE,
1393 iobase + IRCC_LCR_B);
1394
1395 return 0;
1396}
1397
1398
1399
1400
1401
1402
1403
1404static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self)
1405{
1406 struct sk_buff *skb;
1407 int len, msgcnt, lsr;
1408 int iobase = self->io.fir_base;
1409
1410 register_bank(iobase, 0);
1411
1412 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1413#if 0
1414
1415 register_bank(iobase, 0);
1416 outb(0x00, iobase + IRCC_LCR_B);
1417#endif
1418 register_bank(iobase, 0);
1419 outb(inb(iobase + IRCC_LSAR) & ~IRCC_LSAR_ADDRESS_MASK, iobase + IRCC_LSAR);
1420 lsr= inb(iobase + IRCC_LSR);
1421 msgcnt = inb(iobase + IRCC_LCR_B) & 0x08;
1422
1423 IRDA_DEBUG(2, "%s: dma count = %d\n", __FUNCTION__,
1424 get_dma_residue(self->io.dma));
1425
1426 len = self->rx_buff.truesize - get_dma_residue(self->io.dma);
1427
1428
1429 if (lsr & (IRCC_LSR_FRAME_ERROR | IRCC_LSR_CRC_ERROR | IRCC_LSR_SIZE_ERROR)) {
1430 self->stats.rx_errors++;
1431 if (lsr & IRCC_LSR_FRAME_ERROR)
1432 self->stats.rx_frame_errors++;
1433 if (lsr & IRCC_LSR_CRC_ERROR)
1434 self->stats.rx_crc_errors++;
1435 if (lsr & IRCC_LSR_SIZE_ERROR)
1436 self->stats.rx_length_errors++;
1437 if (lsr & (IRCC_LSR_UNDERRUN | IRCC_LSR_OVERRUN))
1438 self->stats.rx_length_errors++;
1439 return;
1440 }
1441
1442
1443 len -= self->io.speed < 4000000 ? 2 : 4;
1444
1445 if (len < 2 || len > 2050) {
1446 IRDA_WARNING("%s(), bogus len=%d\n", __FUNCTION__, len);
1447 return;
1448 }
1449 IRDA_DEBUG(2, "%s: msgcnt = %d, len=%d\n", __FUNCTION__, msgcnt, len);
1450
1451 skb = dev_alloc_skb(len + 1);
1452 if (!skb) {
1453 IRDA_WARNING("%s(), memory squeeze, dropping frame.\n",
1454 __FUNCTION__);
1455 return;
1456 }
1457
1458 skb_reserve(skb, 1);
1459
1460 memcpy(skb_put(skb, len), self->rx_buff.data, len);
1461 self->stats.rx_packets++;
1462 self->stats.rx_bytes += len;
1463
1464 skb->dev = self->netdev;
1465 skb_reset_mac_header(skb);
1466 skb->protocol = htons(ETH_P_IRDA);
1467 netif_rx(skb);
1468}
1469
1470
1471
1472
1473
1474
1475
1476static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self)
1477{
1478 int boguscount = 0;
1479 int iobase;
1480
1481 IRDA_ASSERT(self != NULL, return;);
1482
1483 iobase = self->io.sir_base;
1484
1485
1486
1487
1488
1489 do {
1490 async_unwrap_char(self->netdev, &self->stats, &self->rx_buff,
1491 inb(iobase + UART_RX));
1492
1493
1494 if (boguscount++ > 32) {
1495 IRDA_DEBUG(2, "%s(), breaking!\n", __FUNCTION__);
1496 break;
1497 }
1498 } while (inb(iobase + UART_LSR) & UART_LSR_DR);
1499}
1500
1501
1502
1503
1504
1505
1506
1507
1508static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id)
1509{
1510 struct net_device *dev = (struct net_device *) dev_id;
1511 struct smsc_ircc_cb *self;
1512 int iobase, iir, lcra, lsr;
1513 irqreturn_t ret = IRQ_NONE;
1514
1515 if (dev == NULL) {
1516 printk(KERN_WARNING "%s: irq %d for unknown device.\n",
1517 driver_name, irq);
1518 goto irq_ret;
1519 }
1520
1521 self = netdev_priv(dev);
1522 IRDA_ASSERT(self != NULL, return IRQ_NONE;);
1523
1524
1525 spin_lock(&self->lock);
1526
1527
1528 if (self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED) {
1529 ret = smsc_ircc_interrupt_sir(dev);
1530 goto irq_ret_unlock;
1531 }
1532
1533 iobase = self->io.fir_base;
1534
1535 register_bank(iobase, 0);
1536 iir = inb(iobase + IRCC_IIR);
1537 if (iir == 0)
1538 goto irq_ret_unlock;
1539 ret = IRQ_HANDLED;
1540
1541
1542 outb(0, iobase + IRCC_IER);
1543 lcra = inb(iobase + IRCC_LCR_A);
1544 lsr = inb(iobase + IRCC_LSR);
1545
1546 IRDA_DEBUG(2, "%s(), iir = 0x%02x\n", __FUNCTION__, iir);
1547
1548 if (iir & IRCC_IIR_EOM) {
1549 if (self->io.direction == IO_RECV)
1550 smsc_ircc_dma_receive_complete(self);
1551 else
1552 smsc_ircc_dma_xmit_complete(self);
1553
1554 smsc_ircc_dma_receive(self);
1555 }
1556
1557 if (iir & IRCC_IIR_ACTIVE_FRAME) {
1558
1559 }
1560
1561
1562
1563 register_bank(iobase, 0);
1564 outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER);
1565
1566 irq_ret_unlock:
1567 spin_unlock(&self->lock);
1568 irq_ret:
1569 return ret;
1570}
1571
1572
1573
1574
1575
1576
1577static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev)
1578{
1579 struct smsc_ircc_cb *self = netdev_priv(dev);
1580 int boguscount = 0;
1581 int iobase;
1582 int iir, lsr;
1583
1584
1585
1586
1587 iobase = self->io.sir_base;
1588
1589 iir = inb(iobase + UART_IIR) & UART_IIR_ID;
1590 if (iir == 0)
1591 return IRQ_NONE;
1592 while (iir) {
1593
1594 lsr = inb(iobase + UART_LSR);
1595
1596 IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n",
1597 __FUNCTION__, iir, lsr, iobase);
1598
1599 switch (iir) {
1600 case UART_IIR_RLSI:
1601 IRDA_DEBUG(2, "%s(), RLSI\n", __FUNCTION__);
1602 break;
1603 case UART_IIR_RDI:
1604
1605 smsc_ircc_sir_receive(self);
1606 break;
1607 case UART_IIR_THRI:
1608 if (lsr & UART_LSR_THRE)
1609
1610 smsc_ircc_sir_write_wakeup(self);
1611 break;
1612 default:
1613 IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n",
1614 __FUNCTION__, iir);
1615 break;
1616 }
1617
1618
1619 if (boguscount++ > 100)
1620 break;
1621
1622 iir = inb(iobase + UART_IIR) & UART_IIR_ID;
1623 }
1624
1625 return IRQ_HANDLED;
1626}
1627
1628
1629#if 0
1630
1631
1632
1633
1634
1635
1636static int ircc_is_receiving(struct smsc_ircc_cb *self)
1637{
1638 int status = FALSE;
1639
1640
1641 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1642
1643 IRDA_ASSERT(self != NULL, return FALSE;);
1644
1645 IRDA_DEBUG(0, "%s: dma count = %d\n", __FUNCTION__,
1646 get_dma_residue(self->io.dma));
1647
1648 status = (self->rx_buff.state != OUTSIDE_FRAME);
1649
1650 return status;
1651}
1652#endif
1653
1654static int smsc_ircc_request_irq(struct smsc_ircc_cb *self)
1655{
1656 int error;
1657
1658 error = request_irq(self->io.irq, smsc_ircc_interrupt, 0,
1659 self->netdev->name, self->netdev);
1660 if (error)
1661 IRDA_DEBUG(0, "%s(), unable to allocate irq=%d, err=%d\n",
1662 __FUNCTION__, self->io.irq, error);
1663
1664 return error;
1665}
1666
1667static void smsc_ircc_start_interrupts(struct smsc_ircc_cb *self)
1668{
1669 unsigned long flags;
1670
1671 spin_lock_irqsave(&self->lock, flags);
1672
1673 self->io.speed = 0;
1674 smsc_ircc_change_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED);
1675
1676 spin_unlock_irqrestore(&self->lock, flags);
1677}
1678
1679static void smsc_ircc_stop_interrupts(struct smsc_ircc_cb *self)
1680{
1681 int iobase = self->io.fir_base;
1682 unsigned long flags;
1683
1684 spin_lock_irqsave(&self->lock, flags);
1685
1686 register_bank(iobase, 0);
1687 outb(0, iobase + IRCC_IER);
1688 outb(IRCC_MASTER_RESET, iobase + IRCC_MASTER);
1689 outb(0x00, iobase + IRCC_MASTER);
1690
1691 spin_unlock_irqrestore(&self->lock, flags);
1692}
1693
1694
1695
1696
1697
1698
1699
1700
1701static int smsc_ircc_net_open(struct net_device *dev)
1702{
1703 struct smsc_ircc_cb *self;
1704 char hwname[16];
1705
1706 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1707
1708 IRDA_ASSERT(dev != NULL, return -1;);
1709 self = netdev_priv(dev);
1710 IRDA_ASSERT(self != NULL, return 0;);
1711
1712 if (self->io.suspended) {
1713 IRDA_DEBUG(0, "%s(), device is suspended\n", __FUNCTION__);
1714 return -EAGAIN;
1715 }
1716
1717 if (request_irq(self->io.irq, smsc_ircc_interrupt, 0, dev->name,
1718 (void *) dev)) {
1719 IRDA_DEBUG(0, "%s(), unable to allocate irq=%d\n",
1720 __FUNCTION__, self->io.irq);
1721 return -EAGAIN;
1722 }
1723
1724 smsc_ircc_start_interrupts(self);
1725
1726
1727
1728 sprintf(hwname, "SMSC @ 0x%03x", self->io.fir_base);
1729
1730
1731
1732
1733
1734 self->irlap = irlap_open(dev, &self->qos, hwname);
1735
1736
1737
1738
1739
1740 if (request_dma(self->io.dma, dev->name)) {
1741 smsc_ircc_net_close(dev);
1742
1743 IRDA_WARNING("%s(), unable to allocate DMA=%d\n",
1744 __FUNCTION__, self->io.dma);
1745 return -EAGAIN;
1746 }
1747
1748 netif_start_queue(dev);
1749
1750 return 0;
1751}
1752
1753
1754
1755
1756
1757
1758
1759static int smsc_ircc_net_close(struct net_device *dev)
1760{
1761 struct smsc_ircc_cb *self;
1762
1763 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1764
1765 IRDA_ASSERT(dev != NULL, return -1;);
1766 self = netdev_priv(dev);
1767 IRDA_ASSERT(self != NULL, return 0;);
1768
1769
1770 netif_stop_queue(dev);
1771
1772
1773 if (self->irlap)
1774 irlap_close(self->irlap);
1775 self->irlap = NULL;
1776
1777 smsc_ircc_stop_interrupts(self);
1778
1779
1780 if (!self->io.suspended)
1781 free_irq(self->io.irq, dev);
1782
1783 disable_dma(self->io.dma);
1784 free_dma(self->io.dma);
1785
1786 return 0;
1787}
1788
1789static int smsc_ircc_suspend(struct platform_device *dev, pm_message_t state)
1790{
1791 struct smsc_ircc_cb *self = platform_get_drvdata(dev);
1792
1793 if (!self->io.suspended) {
1794 IRDA_DEBUG(1, "%s, Suspending\n", driver_name);
1795
1796 rtnl_lock();
1797 if (netif_running(self->netdev)) {
1798 netif_device_detach(self->netdev);
1799 smsc_ircc_stop_interrupts(self);
1800 free_irq(self->io.irq, self->netdev);
1801 disable_dma(self->io.dma);
1802 }
1803 self->io.suspended = 1;
1804 rtnl_unlock();
1805 }
1806
1807 return 0;
1808}
1809
1810static int smsc_ircc_resume(struct platform_device *dev)
1811{
1812 struct smsc_ircc_cb *self = platform_get_drvdata(dev);
1813
1814 if (self->io.suspended) {
1815 IRDA_DEBUG(1, "%s, Waking up\n", driver_name);
1816
1817 rtnl_lock();
1818 smsc_ircc_init_chip(self);
1819 if (netif_running(self->netdev)) {
1820 if (smsc_ircc_request_irq(self)) {
1821
1822
1823
1824
1825 unregister_netdevice(self->netdev);
1826 } else {
1827 enable_dma(self->io.dma);
1828 smsc_ircc_start_interrupts(self);
1829 netif_device_attach(self->netdev);
1830 }
1831 }
1832 self->io.suspended = 0;
1833 rtnl_unlock();
1834 }
1835 return 0;
1836}
1837
1838
1839
1840
1841
1842
1843
1844static int __exit smsc_ircc_close(struct smsc_ircc_cb *self)
1845{
1846 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1847
1848 IRDA_ASSERT(self != NULL, return -1;);
1849
1850 platform_device_unregister(self->pldev);
1851
1852
1853 unregister_netdev(self->netdev);
1854
1855 smsc_ircc_stop_interrupts(self);
1856
1857
1858 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__,
1859 self->io.fir_base);
1860
1861 release_region(self->io.fir_base, self->io.fir_ext);
1862
1863 IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__,
1864 self->io.sir_base);
1865
1866 release_region(self->io.sir_base, self->io.sir_ext);
1867
1868 if (self->tx_buff.head)
1869 dma_free_coherent(NULL, self->tx_buff.truesize,
1870 self->tx_buff.head, self->tx_buff_dma);
1871
1872 if (self->rx_buff.head)
1873 dma_free_coherent(NULL, self->rx_buff.truesize,
1874 self->rx_buff.head, self->rx_buff_dma);
1875
1876 free_netdev(self->netdev);
1877
1878 return 0;
1879}
1880
1881static void __exit smsc_ircc_cleanup(void)
1882{
1883 int i;
1884
1885 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
1886
1887 for (i = 0; i < 2; i++) {
1888 if (dev_self[i])
1889 smsc_ircc_close(dev_self[i]);
1890 }
1891
1892 if (pnp_driver_registered)
1893 pnp_unregister_driver(&smsc_ircc_pnp_driver);
1894
1895 platform_driver_unregister(&smsc_ircc_driver);
1896}
1897
1898
1899
1900
1901
1902
1903
1904void smsc_ircc_sir_start(struct smsc_ircc_cb *self)
1905{
1906 struct net_device *dev;
1907 int fir_base, sir_base;
1908
1909 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1910
1911 IRDA_ASSERT(self != NULL, return;);
1912 dev = self->netdev;
1913 IRDA_ASSERT(dev != NULL, return;);
1914 dev->hard_start_xmit = &smsc_ircc_hard_xmit_sir;
1915
1916 fir_base = self->io.fir_base;
1917 sir_base = self->io.sir_base;
1918
1919
1920 outb(IRCC_MASTER_RESET, fir_base + IRCC_MASTER);
1921
1922 #if SMSC_IRCC2_C_SIR_STOP
1923
1924 #endif
1925
1926 register_bank(fir_base, 1);
1927 outb(((inb(fir_base + IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | IRCC_CFGA_IRDA_SIR_A), fir_base + IRCC_SCE_CFGA);
1928
1929
1930 outb(UART_LCR_WLEN8, sir_base + UART_LCR);
1931 outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), sir_base + UART_MCR);
1932
1933
1934 outb(UART_IER_RLSI | UART_IER_RDI |UART_IER_THRI, sir_base + UART_IER);
1935
1936 IRDA_DEBUG(3, "%s() - exit\n", __FUNCTION__);
1937
1938 outb(0x00, fir_base + IRCC_MASTER);
1939}
1940
1941#if SMSC_IRCC2_C_SIR_STOP
1942void smsc_ircc_sir_stop(struct smsc_ircc_cb *self)
1943{
1944 int iobase;
1945
1946 IRDA_DEBUG(3, "%s\n", __FUNCTION__);
1947 iobase = self->io.sir_base;
1948
1949
1950 outb(0, iobase + UART_MCR);
1951
1952
1953 outb(0, iobase + UART_IER);
1954}
1955#endif
1956
1957
1958
1959
1960
1961
1962
1963
1964static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self)
1965{
1966 int actual = 0;
1967 int iobase;
1968 int fcr;
1969
1970 IRDA_ASSERT(self != NULL, return;);
1971
1972 IRDA_DEBUG(4, "%s\n", __FUNCTION__);
1973
1974 iobase = self->io.sir_base;
1975
1976
1977 if (self->tx_buff.len > 0) {
1978
1979 actual = smsc_ircc_sir_write(iobase, self->io.fifo_size,
1980 self->tx_buff.data, self->tx_buff.len);
1981 self->tx_buff.data += actual;
1982 self->tx_buff.len -= actual;
1983 } else {
1984
1985
1986
1987
1988
1989
1990
1991
1992 if (self->new_speed) {
1993 IRDA_DEBUG(5, "%s(), Changing speed to %d.\n",
1994 __FUNCTION__, self->new_speed);
1995 smsc_ircc_sir_wait_hw_transmitter_finish(self);
1996 smsc_ircc_change_speed(self, self->new_speed);
1997 self->new_speed = 0;
1998 } else {
1999
2000 netif_wake_queue(self->netdev);
2001 }
2002 self->stats.tx_packets++;
2003
2004 if (self->io.speed <= 115200) {
2005
2006
2007
2008
2009 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR;
2010 fcr |= self->io.speed < 38400 ?
2011 UART_FCR_TRIGGER_1 : UART_FCR_TRIGGER_14;
2012
2013 outb(fcr, iobase + UART_FCR);
2014
2015
2016 outb(UART_IER_RDI, iobase + UART_IER);
2017 }
2018 }
2019}
2020
2021
2022
2023
2024
2025
2026
2027static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len)
2028{
2029 int actual = 0;
2030
2031
2032 if (!(inb(iobase + UART_LSR) & UART_LSR_THRE)) {
2033 IRDA_WARNING("%s(), failed, fifo not empty!\n", __FUNCTION__);
2034 return 0;
2035 }
2036
2037
2038 while (fifo_size-- > 0 && actual < len) {
2039
2040 outb(buf[actual], iobase + UART_TX);
2041 actual++;
2042 }
2043 return actual;
2044}
2045
2046
2047
2048
2049
2050
2051
2052static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self)
2053{
2054 return (self->rx_buff.state != OUTSIDE_FRAME);
2055}
2056
2057
2058
2059
2060
2061
2062
2063
2064static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self)
2065{
2066 unsigned int i;
2067
2068 IRDA_ASSERT(self != NULL, return;);
2069
2070 for (i = 0; smsc_transceivers[i].name != NULL; i++)
2071 if (smsc_transceivers[i].probe(self->io.fir_base)) {
2072 IRDA_MESSAGE(" %s transceiver found\n",
2073 smsc_transceivers[i].name);
2074 self->transceiver= i + 1;
2075 return;
2076 }
2077
2078 IRDA_MESSAGE("No transceiver found. Defaulting to %s\n",
2079 smsc_transceivers[SMSC_IRCC2_C_DEFAULT_TRANSCEIVER].name);
2080
2081 self->transceiver = SMSC_IRCC2_C_DEFAULT_TRANSCEIVER;
2082}
2083
2084
2085
2086
2087
2088
2089
2090
2091static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed)
2092{
2093 unsigned int trx;
2094
2095 trx = self->transceiver;
2096 if (trx > 0)
2097 smsc_transceivers[trx - 1].set_for_speed(self->io.fir_base, speed);
2098}
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self)
2124{
2125 int iobase = self->io.sir_base;
2126 int count = SMSC_IRCC2_HW_TRANSMITTER_TIMEOUT_US;
2127
2128
2129 while (count-- > 0 && !(inb(iobase + UART_LSR) & UART_LSR_TEMT))
2130 udelay(1);
2131
2132 if (count == 0)
2133 IRDA_DEBUG(0, "%s(): stuck transmitter\n", __FUNCTION__);
2134}
2135
2136
2137
2138
2139
2140
2141
2142
2143static int __init smsc_ircc_look_for_chips(void)
2144{
2145 struct smsc_chip_address *address;
2146 char *type;
2147 unsigned int cfg_base, found;
2148
2149 found = 0;
2150 address = possible_addresses;
2151
2152 while (address->cfg_base) {
2153 cfg_base = address->cfg_base;
2154
2155
2156
2157 if (address->type & SMSCSIO_TYPE_FDC) {
2158 type = "FDC";
2159 if (address->type & SMSCSIO_TYPE_FLAT)
2160 if (!smsc_superio_flat(fdc_chips_flat, cfg_base, type))
2161 found++;
2162
2163 if (address->type & SMSCSIO_TYPE_PAGED)
2164 if (!smsc_superio_paged(fdc_chips_paged, cfg_base, type))
2165 found++;
2166 }
2167 if (address->type & SMSCSIO_TYPE_LPC) {
2168 type = "LPC";
2169 if (address->type & SMSCSIO_TYPE_FLAT)
2170 if (!smsc_superio_flat(lpc_chips_flat, cfg_base, type))
2171 found++;
2172
2173 if (address->type & SMSCSIO_TYPE_PAGED)
2174 if (!smsc_superio_paged(lpc_chips_paged, cfg_base, type))
2175 found++;
2176 }
2177 address++;
2178 }
2179 return found;
2180}
2181
2182
2183
2184
2185
2186
2187
2188static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfgbase, char *type)
2189{
2190 unsigned short firbase, sirbase;
2191 u8 mode, dma, irq;
2192 int ret = -ENODEV;
2193
2194 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2195
2196 if (smsc_ircc_probe(cfgbase, SMSCSIOFLAT_DEVICEID_REG, chips, type) == NULL)
2197 return ret;
2198
2199 outb(SMSCSIOFLAT_UARTMODE0C_REG, cfgbase);
2200 mode = inb(cfgbase + 1);
2201
2202
2203
2204 if (!(mode & SMSCSIOFLAT_UART2MODE_VAL_IRDA))
2205 IRDA_WARNING("%s(): IrDA not enabled\n", __FUNCTION__);
2206
2207 outb(SMSCSIOFLAT_UART2BASEADDR_REG, cfgbase);
2208 sirbase = inb(cfgbase + 1) << 2;
2209
2210
2211 outb(SMSCSIOFLAT_FIRBASEADDR_REG, cfgbase);
2212 firbase = inb(cfgbase + 1) << 3;
2213
2214
2215 outb(SMSCSIOFLAT_FIRDMASELECT_REG, cfgbase);
2216 dma = inb(cfgbase + 1) & SMSCSIOFLAT_FIRDMASELECT_MASK;
2217
2218
2219 outb(SMSCSIOFLAT_UARTIRQSELECT_REG, cfgbase);
2220 irq = inb(cfgbase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK;
2221
2222 IRDA_MESSAGE("%s(): fir: 0x%02x, sir: 0x%02x, dma: %02d, irq: %d, mode: 0x%02x\n", __FUNCTION__, firbase, sirbase, dma, irq, mode);
2223
2224 if (firbase && smsc_ircc_open(firbase, sirbase, dma, irq) == 0)
2225 ret = 0;
2226
2227
2228 outb(SMSCSIO_CFGEXITKEY, cfgbase);
2229
2230 return ret;
2231}
2232
2233
2234
2235
2236
2237
2238
2239static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type)
2240{
2241 unsigned short fir_io, sir_io;
2242 int ret = -ENODEV;
2243
2244 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2245
2246 if (smsc_ircc_probe(cfg_base, 0x20, chips, type) == NULL)
2247 return ret;
2248
2249
2250 outb(0x07, cfg_base);
2251 outb(0x05, cfg_base + 1);
2252
2253
2254 outb(0x60, cfg_base);
2255 sir_io = inb(cfg_base + 1) << 8;
2256 outb(0x61, cfg_base);
2257 sir_io |= inb(cfg_base + 1);
2258
2259
2260 outb(0x62, cfg_base);
2261 fir_io = inb(cfg_base + 1) << 8;
2262 outb(0x63, cfg_base);
2263 fir_io |= inb(cfg_base + 1);
2264 outb(0x2b, cfg_base);
2265
2266 if (fir_io && smsc_ircc_open(fir_io, sir_io, ircc_dma, ircc_irq) == 0)
2267 ret = 0;
2268
2269
2270 outb(SMSCSIO_CFGEXITKEY, cfg_base);
2271
2272 return ret;
2273}
2274
2275
2276static int __init smsc_access(unsigned short cfg_base, unsigned char reg)
2277{
2278 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2279
2280 outb(reg, cfg_base);
2281 return inb(cfg_base) != reg ? -1 : 0;
2282}
2283
2284static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type)
2285{
2286 u8 devid, xdevid, rev;
2287
2288 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
2289
2290
2291
2292 outb(SMSCSIO_CFGEXITKEY, cfg_base);
2293
2294 if (inb(cfg_base) == SMSCSIO_CFGEXITKEY)
2295 return NULL;
2296
2297 outb(reg, cfg_base);
2298
2299 xdevid = inb(cfg_base + 1);
2300
2301
2302
2303 outb(SMSCSIO_CFGACCESSKEY, cfg_base);
2304
2305 #if 0
2306 if (smsc_access(cfg_base,0x55))
2307 return NULL;
2308 #endif
2309
2310
2311
2312 if (smsc_access(cfg_base, reg))
2313 return NULL;
2314
2315 devid = inb(cfg_base + 1);
2316
2317 if (devid == 0 || devid == 0xff)
2318 return NULL;
2319
2320
2321
2322 if (smsc_access(cfg_base, reg + 1))
2323 return NULL;
2324
2325 rev = inb(cfg_base + 1);
2326
2327 if (rev >= 128)
2328 return NULL;
2329
2330 if (devid == xdevid)
2331 return NULL;
2332
2333
2334
2335 while (chip->devid != devid) {
2336
2337 chip++;
2338
2339 if (chip->name == NULL)
2340 return NULL;
2341 }
2342
2343 IRDA_MESSAGE("found SMC SuperIO Chip (devid=0x%02x rev=%02X base=0x%04x): %s%s\n",
2344 devid, rev, cfg_base, type, chip->name);
2345
2346 if (chip->rev > rev) {
2347 IRDA_MESSAGE("Revision higher than expected\n");
2348 return NULL;
2349 }
2350
2351 if (chip->flags & NoIRDA)
2352 IRDA_MESSAGE("chipset does not support IRDA\n");
2353
2354 return chip;
2355}
2356
2357static int __init smsc_superio_fdc(unsigned short cfg_base)
2358{
2359 int ret = -1;
2360
2361 if (!request_region(cfg_base, 2, driver_name)) {
2362 IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n",
2363 __FUNCTION__, cfg_base);
2364 } else {
2365 if (!smsc_superio_flat(fdc_chips_flat, cfg_base, "FDC") ||
2366 !smsc_superio_paged(fdc_chips_paged, cfg_base, "FDC"))
2367 ret = 0;
2368
2369 release_region(cfg_base, 2);
2370 }
2371
2372 return ret;
2373}
2374
2375static int __init smsc_superio_lpc(unsigned short cfg_base)
2376{
2377 int ret = -1;
2378
2379 if (!request_region(cfg_base, 2, driver_name)) {
2380 IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n",
2381 __FUNCTION__, cfg_base);
2382 } else {
2383 if (!smsc_superio_flat(lpc_chips_flat, cfg_base, "LPC") ||
2384 !smsc_superio_paged(lpc_chips_paged, cfg_base, "LPC"))
2385 ret = 0;
2386
2387 release_region(cfg_base, 2);
2388 }
2389 return ret;
2390}
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406#ifdef CONFIG_PCI
2407#define PCIID_VENDOR_INTEL 0x8086
2408#define PCIID_VENDOR_ALI 0x10b9
2409static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __initdata = {
2410
2411
2412
2413
2414
2415
2416 {
2417
2418 .vendor = PCIID_VENDOR_INTEL,
2419 .device = 0x24cc,
2420 .subvendor = 0x103c,
2421 .subdevice = 0x08bc,
2422 .sir_io = 0x02f8,
2423 .fir_io = 0x0130,
2424 .fir_irq = 0x05,
2425 .fir_dma = 0x03,
2426 .cfg_base = 0x004e,
2427 .preconfigure = preconfigure_through_82801,
2428 .name = "HP nx5000 family",
2429 },
2430 {
2431 .vendor = PCIID_VENDOR_INTEL,
2432 .device = 0x24cc,
2433 .subvendor = 0x103c,
2434 .subdevice = 0x088c,
2435
2436 .sir_io = 0x02f8,
2437 .fir_io = 0x0130,
2438 .fir_irq = 0x05,
2439 .fir_dma = 0x03,
2440 .cfg_base = 0x004e,
2441 .preconfigure = preconfigure_through_82801,
2442 .name = "HP nc8000 family",
2443 },
2444 {
2445 .vendor = PCIID_VENDOR_INTEL,
2446 .device = 0x24cc,
2447 .subvendor = 0x103c,
2448 .subdevice = 0x0890,
2449 .sir_io = 0x02f8,
2450 .fir_io = 0x0130,
2451 .fir_irq = 0x05,
2452 .fir_dma = 0x03,
2453 .cfg_base = 0x004e,
2454 .preconfigure = preconfigure_through_82801,
2455 .name = "HP nc6000 family",
2456 },
2457 {
2458 .vendor = PCIID_VENDOR_INTEL,
2459 .device = 0x24cc,
2460 .subvendor = 0x0e11,
2461 .subdevice = 0x0860,
2462
2463 .sir_io = 0x02e8,
2464 .fir_io = 0x02f8,
2465 .fir_irq = 0x07,
2466 .fir_dma = 0x03,
2467 .cfg_base = 0x002e,
2468 .preconfigure = preconfigure_through_82801,
2469 .name = "Compaq x1000 family",
2470 },
2471 {
2472
2473 .vendor = PCIID_VENDOR_INTEL,
2474 .device = 0x24c0,
2475 .subvendor = 0x1179,
2476 .subdevice = 0xffff,
2477 .sir_io = 0x03f8,
2478 .fir_io = 0x0130,
2479 .fir_irq = 0x07,
2480 .fir_dma = 0x01,
2481 .cfg_base = 0x002e,
2482 .preconfigure = preconfigure_through_82801,
2483 .name = "Toshiba laptop with Intel 82801DB/DBL LPC bridge",
2484 },
2485 {
2486 .vendor = PCIID_VENDOR_INTEL,
2487 .device = 0x248c,
2488 .subvendor = 0x1179,
2489 .subdevice = 0xffff,
2490 .sir_io = 0x03f8,
2491 .fir_io = 0x0130,
2492 .fir_irq = 0x03,
2493 .fir_dma = 0x03,
2494 .cfg_base = 0x002e,
2495 .preconfigure = preconfigure_through_82801,
2496 .name = "Toshiba laptop with Intel 82801CAM ISA bridge",
2497 },
2498 {
2499
2500 .vendor = PCIID_VENDOR_INTEL,
2501 .device = 0x24cc,
2502 .subvendor = 0x1179,
2503 .subdevice = 0xffff,
2504 .sir_io = 0x03f8,
2505 .fir_io = 0x0130,
2506 .fir_irq = 0x03,
2507 .fir_dma = 0x03,
2508 .cfg_base = 0x002e,
2509 .preconfigure = preconfigure_through_82801,
2510 .name = "Toshiba laptop with Intel 8281DBM LPC bridge",
2511 },
2512 {
2513
2514 .vendor = PCIID_VENDOR_ALI,
2515 .device = 0x1533,
2516 .subvendor = 0x1179,
2517 .subdevice = 0xffff,
2518 .sir_io = 0x02e8,
2519 .fir_io = 0x02f8,
2520 .fir_irq = 0x07,
2521 .fir_dma = 0x03,
2522 .cfg_base = 0x002e,
2523 .preconfigure = preconfigure_through_ali,
2524 .name = "Toshiba laptop with ALi ISA bridge",
2525 },
2526 { }
2527};
2528
2529
2530
2531
2532
2533
2534
2535static int __init preconfigure_smsc_chip(struct
2536 smsc_ircc_subsystem_configuration
2537 *conf)
2538{
2539 unsigned short iobase = conf->cfg_base;
2540 unsigned char tmpbyte;
2541
2542 outb(LPC47N227_CFGACCESSKEY, iobase);
2543 outb(SMSCSIOFLAT_DEVICEID_REG, iobase);
2544 tmpbyte = inb(iobase +1);
2545 IRDA_DEBUG(0,
2546 "Detected Chip id: 0x%02x, setting up registers...\n",
2547 tmpbyte);
2548
2549
2550 outb(0x24, iobase);
2551 outb(0x00, iobase + 1);
2552 outb(SMSCSIOFLAT_UART2BASEADDR_REG, iobase);
2553 outb( (conf->sir_io >> 2), iobase + 1);
2554 tmpbyte = inb(iobase + 1);
2555 if (tmpbyte != (conf->sir_io >> 2) ) {
2556 IRDA_WARNING("ERROR: could not configure SIR ioport.\n");
2557 IRDA_WARNING("Try to supply ircc_cfg argument.\n");
2558 return -ENXIO;
2559 }
2560
2561
2562 outb(SMSCSIOFLAT_UARTIRQSELECT_REG, iobase);
2563 tmpbyte = inb(iobase + 1);
2564 tmpbyte &= SMSCSIOFLAT_UART1IRQSELECT_MASK;
2565 tmpbyte |= (conf->fir_irq & SMSCSIOFLAT_UART2IRQSELECT_MASK);
2566 outb(tmpbyte, iobase + 1);
2567 tmpbyte = inb(iobase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK;
2568 if (tmpbyte != conf->fir_irq) {
2569 IRDA_WARNING("ERROR: could not configure FIR IRQ channel.\n");
2570 return -ENXIO;
2571 }
2572
2573
2574 outb(SMSCSIOFLAT_FIRBASEADDR_REG, iobase);
2575 outb((conf->fir_io >> 3), iobase + 1);
2576 tmpbyte = inb(iobase + 1);
2577 if (tmpbyte != (conf->fir_io >> 3) ) {
2578 IRDA_WARNING("ERROR: could not configure FIR I/O port.\n");
2579 return -ENXIO;
2580 }
2581
2582
2583 outb(SMSCSIOFLAT_FIRDMASELECT_REG, iobase);
2584 outb((conf->fir_dma & LPC47N227_FIRDMASELECT_MASK), iobase + 1);
2585 tmpbyte = inb(iobase + 1) & LPC47N227_FIRDMASELECT_MASK;
2586 if (tmpbyte != (conf->fir_dma & LPC47N227_FIRDMASELECT_MASK)) {
2587 IRDA_WARNING("ERROR: could not configure FIR DMA channel.\n");
2588 return -ENXIO;
2589 }
2590
2591 outb(SMSCSIOFLAT_UARTMODE0C_REG, iobase);
2592 tmpbyte = inb(iobase + 1);
2593 tmpbyte &= ~SMSCSIOFLAT_UART2MODE_MASK |
2594 SMSCSIOFLAT_UART2MODE_VAL_IRDA;
2595 outb(tmpbyte, iobase + 1);
2596
2597 outb(LPC47N227_APMBOOTDRIVE_REG, iobase);
2598 tmpbyte = inb(iobase + 1);
2599 outb(tmpbyte | LPC47N227_UART2AUTOPWRDOWN_MASK, iobase + 1);
2600
2601
2602 outb(0x0a, iobase);
2603 tmpbyte = inb(iobase + 1);
2604 outb(tmpbyte | 0x40, iobase + 1);
2605
2606 outb(LPC47N227_UART12POWER_REG, iobase);
2607 tmpbyte = inb(iobase + 1);
2608 outb(tmpbyte | LPC47N227_UART2POWERDOWN_MASK, iobase + 1);
2609
2610 outb(LPC47N227_FDCPOWERVALIDCONF_REG, iobase);
2611 tmpbyte = inb(iobase + 1);
2612 outb(tmpbyte | LPC47N227_VALID_MASK, iobase + 1);
2613
2614 outb(LPC47N227_CFGEXITKEY, iobase);
2615
2616 return 0;
2617}
2618
2619
2620#define VID 0x00
2621#define DID 0x02
2622#define PIRQ_A_D_ROUT 0x60
2623#define SIRQ_CNTL 0x64
2624#define PIRQ_E_H_ROUT 0x68
2625#define PCI_DMA_C 0x90
2626
2627#define COM_DEC 0xe0
2628#define GEN1_DEC 0xe4
2629#define LPC_EN 0xe6
2630#define GEN2_DEC 0xec
2631
2632
2633
2634
2635
2636static int __init preconfigure_through_82801(struct pci_dev *dev,
2637 struct
2638 smsc_ircc_subsystem_configuration
2639 *conf)
2640{
2641 unsigned short tmpword;
2642 unsigned char tmpbyte;
2643
2644 IRDA_MESSAGE("Setting up Intel 82801 controller and SMSC device\n");
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663 pci_read_config_byte(dev, COM_DEC, &tmpbyte);
2664 tmpbyte &= 0xf8;
2665 switch(conf->sir_io) {
2666 case 0x3f8:
2667 tmpbyte |= 0x00;
2668 break;
2669 case 0x2f8:
2670 tmpbyte |= 0x01;
2671 break;
2672 case 0x220:
2673 tmpbyte |= 0x02;
2674 break;
2675 case 0x228:
2676 tmpbyte |= 0x03;
2677 break;
2678 case 0x238:
2679 tmpbyte |= 0x04;
2680 break;
2681 case 0x2e8:
2682 tmpbyte |= 0x05;
2683 break;
2684 case 0x338:
2685 tmpbyte |= 0x06;
2686 break;
2687 case 0x3e8:
2688 tmpbyte |= 0x07;
2689 break;
2690 default:
2691 tmpbyte |= 0x01;
2692 }
2693 IRDA_DEBUG(1, "COM_DEC (write): 0x%02x\n", tmpbyte);
2694 pci_write_config_byte(dev, COM_DEC, tmpbyte);
2695
2696
2697 pci_read_config_word(dev, LPC_EN, &tmpword);
2698
2699
2700
2701 switch(conf->cfg_base) {
2702 case 0x04e:
2703 tmpword |= 0x2000;
2704 break;
2705 case 0x02e:
2706 tmpword |= 0x1000;
2707 break;
2708 case 0x062:
2709 tmpword |= 0x0800;
2710 break;
2711 case 0x060:
2712 tmpword |= 0x0400;
2713 break;
2714 default:
2715 IRDA_WARNING("Uncommon I/O base address: 0x%04x\n",
2716 conf->cfg_base);
2717 break;
2718 }
2719 tmpword &= 0xfffd;
2720 tmpword |= 0x0001;
2721 IRDA_DEBUG(1, "LPC_EN (write): 0x%04x\n", tmpword);
2722 pci_write_config_word(dev, LPC_EN, tmpword);
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740 pci_read_config_word(dev, PCI_DMA_C, &tmpword);
2741 switch(conf->fir_dma) {
2742 case 0x07:
2743 tmpword |= 0xc000;
2744 break;
2745 case 0x06:
2746 tmpword |= 0x3000;
2747 break;
2748 case 0x05:
2749 tmpword |= 0x0c00;
2750 break;
2751 case 0x03:
2752 tmpword |= 0x00c0;
2753 break;
2754 case 0x02:
2755 tmpword |= 0x0030;
2756 break;
2757 case 0x01:
2758 tmpword |= 0x000c;
2759 break;
2760 case 0x00:
2761 tmpword |= 0x0003;
2762 break;
2763 default:
2764 break;
2765 }
2766 IRDA_DEBUG(1, "PCI_DMA_C (write): 0x%04x\n", tmpword);
2767 pci_write_config_word(dev, PCI_DMA_C, tmpword);
2768
2769
2770
2771
2772
2773
2774
2775 tmpword = conf->fir_io & 0xfff8;
2776 tmpword |= 0x0001;
2777 IRDA_DEBUG(1, "GEN2_DEC (write): 0x%04x\n", tmpword);
2778 pci_write_config_word(dev, GEN2_DEC, tmpword);
2779
2780
2781 return preconfigure_smsc_chip(conf);
2782}
2783
2784
2785
2786
2787
2788
2789static void __init preconfigure_ali_port(struct pci_dev *dev,
2790 unsigned short port)
2791{
2792 unsigned char reg;
2793
2794 unsigned char mask;
2795 unsigned char tmpbyte;
2796
2797 switch(port) {
2798 case 0x0130:
2799 case 0x0178:
2800 reg = 0xb0;
2801 mask = 0x80;
2802 break;
2803 case 0x03f8:
2804 reg = 0xb4;
2805 mask = 0x80;
2806 break;
2807 case 0x02f8:
2808 reg = 0xb4;
2809 mask = 0x30;
2810 break;
2811 case 0x02e8:
2812 reg = 0xb4;
2813 mask = 0x08;
2814 break;
2815 default:
2816 IRDA_ERROR("Failed to configure unsupported port on ALi 1533 bridge: 0x%04x\n", port);
2817 return;
2818 }
2819
2820 pci_read_config_byte(dev, reg, &tmpbyte);
2821
2822 tmpbyte |= mask;
2823 pci_write_config_byte(dev, reg, tmpbyte);
2824 IRDA_MESSAGE("Activated ALi 1533 ISA bridge port 0x%04x.\n", port);
2825 return;
2826}
2827
2828static int __init preconfigure_through_ali(struct pci_dev *dev,
2829 struct
2830 smsc_ircc_subsystem_configuration
2831 *conf)
2832{
2833
2834 preconfigure_ali_port(dev, conf->sir_io);
2835 preconfigure_ali_port(dev, conf->fir_io);
2836
2837
2838 return preconfigure_smsc_chip(conf);
2839}
2840
2841static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,
2842 unsigned short ircc_fir,
2843 unsigned short ircc_sir,
2844 unsigned char ircc_dma,
2845 unsigned char ircc_irq)
2846{
2847 struct pci_dev *dev = NULL;
2848 unsigned short ss_vendor = 0x0000;
2849 unsigned short ss_device = 0x0000;
2850 int ret = 0;
2851
2852 dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
2853
2854 while (dev != NULL) {
2855 struct smsc_ircc_subsystem_configuration *conf;
2856
2857
2858
2859
2860
2861
2862
2863 if (dev->subsystem_vendor != 0x0000U) {
2864 ss_vendor = dev->subsystem_vendor;
2865 ss_device = dev->subsystem_device;
2866 }
2867 conf = subsystem_configurations;
2868 for( ; conf->subvendor; conf++) {
2869 if(conf->vendor == dev->vendor &&
2870 conf->device == dev->device &&
2871 conf->subvendor == ss_vendor &&
2872
2873 (conf->subdevice == ss_device ||
2874 conf->subdevice == 0xffff)) {
2875 struct smsc_ircc_subsystem_configuration
2876 tmpconf;
2877
2878 memcpy(&tmpconf, conf,
2879 sizeof(struct smsc_ircc_subsystem_configuration));
2880
2881
2882
2883
2884
2885 if (ircc_cfg != 0)
2886 tmpconf.cfg_base = ircc_cfg;
2887 if (ircc_fir != 0)
2888 tmpconf.fir_io = ircc_fir;
2889 if (ircc_sir != 0)
2890 tmpconf.sir_io = ircc_sir;
2891 if (ircc_dma != DMA_INVAL)
2892 tmpconf.fir_dma = ircc_dma;
2893 if (ircc_irq != IRQ_INVAL)
2894 tmpconf.fir_irq = ircc_irq;
2895
2896 IRDA_MESSAGE("Detected unconfigured %s SMSC IrDA chip, pre-configuring device.\n", conf->name);
2897 if (conf->preconfigure)
2898 ret = conf->preconfigure(dev, &tmpconf);
2899 else
2900 ret = -ENODEV;
2901 }
2902 }
2903 dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
2904 }
2905
2906 return ret;
2907}
2908#endif
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed)
2925{
2926 unsigned long jiffies_now, jiffies_timeout;
2927 u8 val;
2928
2929 jiffies_now = jiffies;
2930 jiffies_timeout = jiffies + SMSC_IRCC2_ATC_PROGRAMMING_TIMEOUT_JIFFIES;
2931
2932
2933 register_bank(fir_base, 4);
2934 outb((inb(fir_base + IRCC_ATC) & IRCC_ATC_MASK) | IRCC_ATC_nPROGREADY|IRCC_ATC_ENABLE,
2935 fir_base + IRCC_ATC);
2936
2937 while ((val = (inb(fir_base + IRCC_ATC) & IRCC_ATC_nPROGREADY)) &&
2938 !time_after(jiffies, jiffies_timeout))
2939 ;
2940
2941 if (val)
2942 IRDA_WARNING("%s(): ATC: 0x%02x\n", __FUNCTION__,
2943 inb(fir_base + IRCC_ATC));
2944}
2945
2946
2947
2948
2949
2950
2951
2952
2953static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base)
2954{
2955 return 0;
2956}
2957
2958
2959
2960
2961
2962
2963
2964
2965static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed)
2966{
2967 u8 fast_mode;
2968
2969 switch (speed) {
2970 default:
2971 case 576000 :
2972 fast_mode = 0;
2973 break;
2974 case 1152000 :
2975 case 4000000 :
2976 fast_mode = IRCC_LCR_A_FAST;
2977 break;
2978 }
2979 register_bank(fir_base, 0);
2980 outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast_mode, fir_base + IRCC_LCR_A);
2981}
2982
2983
2984
2985
2986
2987
2988
2989
2990static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base)
2991{
2992 return 0;
2993}
2994
2995
2996
2997
2998
2999
3000
3001
3002static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed)
3003{
3004 u8 fast_mode;
3005
3006 switch (speed) {
3007 default:
3008 case 576000 :
3009 fast_mode = 0;
3010 break;
3011 case 1152000 :
3012 case 4000000 :
3013 fast_mode = IRCC_LCR_A_GP_DATA;
3014 break;
3015
3016 }
3017
3018 register_bank(fir_base, 0);
3019 outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast_mode, fir_base + IRCC_LCR_A);
3020}
3021
3022
3023
3024
3025
3026
3027
3028
3029static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base)
3030{
3031 return 0;
3032}
3033
3034
3035module_init(smsc_ircc_init);
3036module_exit(smsc_ircc_cleanup);
3037