43 #include <linux/module.h>
44 #include <linux/kernel.h>
45 #include <linux/types.h>
47 #include <linux/netdevice.h>
52 #include <linux/rtnetlink.h>
61 #include <asm/byteorder.h>
66 #include <linux/pci.h>
81 static bool smsc_nopnp =
true;
83 MODULE_PARM_DESC(nopnp,
"Do not use PNP to detect controller settings, defaults to true");
107 static int ircc_transceiver;
114 struct smsc_ircc_subsystem_configuration {
119 unsigned short sir_io;
120 unsigned short fir_io;
121 unsigned char fir_irq;
122 unsigned char fir_dma;
123 unsigned short cfg_base;
124 int (*preconfigure)(
struct pci_dev *
dev,
struct smsc_ircc_subsystem_configuration *conf);
177 #define SMSC_IRCC2_DRIVER_NAME "smsc-ircc2"
179 #define SMSC_IRCC2_C_IRDA_FALLBACK_SPEED 9600
180 #define SMSC_IRCC2_C_DEFAULT_TRANSCEIVER 1
181 #define SMSC_IRCC2_C_NET_TIMEOUT 0
182 #define SMSC_IRCC2_C_SIR_STOP 0
188 static int smsc_ircc_open(
unsigned int firbase,
unsigned int sirbase,
u8 dma,
u8 irq);
189 static int smsc_ircc_present(
unsigned int fir_base,
unsigned int sir_base);
190 static void smsc_ircc_setup_io(
struct smsc_ircc_cb *
self,
unsigned int fir_base,
unsigned int sir_base,
u8 dma,
u8 irq);
191 static void smsc_ircc_setup_qos(
struct smsc_ircc_cb *
self);
192 static void smsc_ircc_init_chip(
struct smsc_ircc_cb *
self);
194 static int smsc_ircc_dma_receive(
struct smsc_ircc_cb *
self);
195 static void smsc_ircc_dma_receive_complete(
struct smsc_ircc_cb *
self);
196 static void smsc_ircc_sir_receive(
struct smsc_ircc_cb *
self);
201 static void smsc_ircc_dma_xmit(
struct smsc_ircc_cb *
self,
int bofs);
202 static void smsc_ircc_dma_xmit_complete(
struct smsc_ircc_cb *
self);
203 static void smsc_ircc_change_speed(
struct smsc_ircc_cb *
self,
u32 speed);
204 static void smsc_ircc_set_sir_speed(
struct smsc_ircc_cb *
self,
u32 speed);
207 static void smsc_ircc_sir_start(
struct smsc_ircc_cb *
self);
208 #if SMSC_IRCC2_C_SIR_STOP
209 static void smsc_ircc_sir_stop(
struct smsc_ircc_cb *
self);
211 static void smsc_ircc_sir_write_wakeup(
struct smsc_ircc_cb *
self);
216 #if SMSC_IRCC2_C_NET_TIMEOUT
219 static int smsc_ircc_is_receiving(
struct smsc_ircc_cb *
self);
220 static void smsc_ircc_probe_transceiver(
struct smsc_ircc_cb *
self);
221 static void smsc_ircc_set_transceiver_for_speed(
struct smsc_ircc_cb *
self,
u32 speed);
222 static void smsc_ircc_sir_wait_hw_transmitter_finish(
struct smsc_ircc_cb *
self);
225 static int __init smsc_ircc_look_for_chips(
void);
229 static int __init smsc_superio_fdc(
unsigned short cfg_base);
230 static int __init smsc_superio_lpc(
unsigned short cfg_base);
232 static int __init preconfigure_smsc_chip(
struct smsc_ircc_subsystem_configuration *conf);
233 static int __init preconfigure_through_82801(
struct pci_dev *
dev,
struct smsc_ircc_subsystem_configuration *conf);
235 unsigned short port);
236 static int __init preconfigure_through_ali(
struct pci_dev *
dev,
struct smsc_ircc_subsystem_configuration *conf);
237 static int __init smsc_ircc_preconfigure_subsystems(
unsigned short ircc_cfg,
238 unsigned short ircc_fir,
239 unsigned short ircc_sir,
240 unsigned char ircc_dma,
241 unsigned char ircc_irq);
246 static void smsc_ircc_set_transceiver_toshiba_sat1800(
int fir_base,
u32 speed);
247 static int smsc_ircc_probe_transceiver_toshiba_sat1800(
int fir_base);
248 static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(
int fir_base,
u32 speed);
249 static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(
int fir_base);
250 static void smsc_ircc_set_transceiver_smsc_ircc_atc(
int fir_base,
u32 speed);
251 static int smsc_ircc_probe_transceiver_smsc_ircc_atc(
int fir_base);
259 .suspend = smsc_ircc_suspend,
260 .resume = smsc_ircc_resume,
270 {
"Toshiba Satellite 1800 (GP data pin select)", smsc_ircc_set_transceiver_toshiba_sat1800, smsc_ircc_probe_transceiver_toshiba_sat1800 },
271 {
"Fast pin select", smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select, smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select },
272 {
"ATC IRMode", smsc_ircc_set_transceiver_smsc_ircc_atc, smsc_ircc_probe_transceiver_smsc_ircc_atc },
275 #define SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS (ARRAY_SIZE(smsc_transceivers) - 1)
342 #define SMSCSIO_TYPE_FDC 1
343 #define SMSCSIO_TYPE_LPC 2
344 #define SMSCSIO_TYPE_FLAT 4
345 #define SMSCSIO_TYPE_PAGED 8
360 static unsigned short dev_count;
362 static inline void register_bank(
int iobase,
int bank)
370 { .id =
"SMCf010", .driver_data = 0 },
376 static int pnp_driver_registered;
382 unsigned int firbase, sirbase;
385 if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) &&
386 pnp_dma_valid(dev, 0) && pnp_irq_valid(dev, 0)))
389 sirbase = pnp_port_start(dev, 0);
390 firbase = pnp_port_start(dev, 1);
394 if (smsc_ircc_open(firbase, sirbase, dma, irq))
400 static struct pnp_driver smsc_ircc_pnp_driver = {
401 .name =
"smsc-ircc2",
402 .id_table = smsc_ircc_pnp_table,
403 .probe = smsc_ircc_pnp_probe,
406 static struct pnp_driver smsc_ircc_pnp_driver;
417 static int __init smsc_ircc_legacy_probe(
void)
422 if (smsc_ircc_preconfigure_subsystems(ircc_cfg, ircc_fir, ircc_sir, ircc_dma, ircc_irq) < 0) {
428 if (ircc_fir > 0 && ircc_sir > 0) {
429 IRDA_MESSAGE(
" Overriding FIR address 0x%04x\n", ircc_fir);
430 IRDA_MESSAGE(
" Overriding SIR address 0x%04x\n", ircc_sir);
432 if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq))
440 "0x%04x\n", ircc_cfg);
441 if (!smsc_superio_fdc(ircc_cfg))
443 if (!smsc_superio_lpc(ircc_cfg))
447 if (smsc_ircc_look_for_chips() > 0)
459 static int __init smsc_ircc_init(
void)
474 ircc_cfg || ircc_fir || ircc_sir ||
476 ret = smsc_ircc_legacy_probe();
479 pnp_driver_registered = 1;
483 if (pnp_driver_registered)
496 if (self->io.speed > 115200)
497 return smsc_ircc_hard_xmit_fir(skb, dev);
499 return smsc_ircc_hard_xmit_sir(skb, dev);
503 .ndo_open = smsc_ircc_net_open,
504 .ndo_stop = smsc_ircc_net_close,
505 .ndo_do_ioctl = smsc_ircc_net_ioctl,
506 .ndo_start_xmit = smsc_ircc_net_xmit,
507 #if SMSC_IRCC2_C_NET_TIMEOUT
508 .ndo_tx_timeout = smsc_ircc_timeout,
518 static int __devinit smsc_ircc_open(
unsigned int fir_base,
unsigned int sir_base,
u8 dma,
u8 irq)
526 err = smsc_ircc_present(fir_base, sir_base);
541 IRDA_WARNING(
"%s() can't allocate net device\n", __func__);
545 #if SMSC_IRCC2_C_NET_TIMEOUT
550 self = netdev_priv(dev);
554 dev->
base_addr =
self->io.fir_base = fir_base;
555 dev->
irq =
self->io.irq =
irq;
558 dev_self[dev_count] =
self;
567 if (self->rx_buff.head ==
NULL) {
568 IRDA_ERROR(
"%s, Can't allocate memory for receive buffer!\n",
576 if (self->tx_buff.head ==
NULL) {
577 IRDA_ERROR(
"%s, Can't allocate memory for transmit buffer!\n",
582 memset(self->rx_buff.head, 0, self->rx_buff.truesize);
583 memset(self->tx_buff.head, 0, self->tx_buff.truesize);
585 self->rx_buff.in_frame =
FALSE;
587 self->tx_buff.data =
self->tx_buff.head;
588 self->rx_buff.data =
self->rx_buff.head;
590 smsc_ircc_setup_io(
self, fir_base, sir_base, dma, irq);
591 smsc_ircc_setup_qos(
self);
592 smsc_ircc_init_chip(
self);
594 if (ircc_transceiver > 0 &&
596 self->transceiver = ircc_transceiver;
598 smsc_ircc_probe_transceiver(
self);
602 IRDA_ERROR(
"%s, Network device registration failed!\n",
609 if (IS_ERR(self->pldev)) {
610 err = PTR_ERR(self->pldev);
613 platform_set_drvdata(self->pldev,
self);
625 self->tx_buff.head, self->tx_buff_dma);
628 self->rx_buff.head, self->rx_buff_dma);
631 dev_self[dev_count] =
NULL;
645 static int smsc_ircc_present(
unsigned int fir_base,
unsigned int sir_base)
663 register_bank(fir_base, 3);
673 if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) {
678 IRDA_MESSAGE(
"SMsC IrDA Controller found\n IrCC version %d.%d, "
679 "firport 0x%03x, sirport 0x%03x dma=%d, irq=%d\n",
680 chip & 0x0f, version, fir_base, sir_base, dma, irq);
698 static void smsc_ircc_setup_io(
struct smsc_ircc_cb *
self,
699 unsigned int fir_base,
unsigned int sir_base,
702 unsigned char config, chip_dma, chip_irq;
704 register_bank(fir_base, 3);
709 self->io.fir_base = fir_base;
710 self->io.sir_base = sir_base;
718 IRDA_MESSAGE(
"%s, Overriding IRQ - chip says %d, using %d\n",
722 self->io.irq = chip_irq;
726 IRDA_MESSAGE(
"%s, Overriding DMA - chip says %d, using %d\n",
730 self->io.dma = chip_dma;
740 static void smsc_ircc_setup_qos(
struct smsc_ircc_cb *
self)
759 static void smsc_ircc_init_chip(
struct smsc_ircc_cb *
self)
761 int iobase =
self->io.fir_base;
763 register_bank(iobase, 0);
767 register_bank(iobase, 1);
781 register_bank(iobase, 4);
784 register_bank(iobase, 0);
808 self = netdev_priv(dev);
812 IRDA_DEBUG(2,
"%s(), %s, (cmd=0x%X)\n", __func__, dev->
name, cmd);
822 smsc_ircc_change_speed(
self, irq->ifr_baudrate);
823 spin_unlock_irqrestore(&self->lock, flags);
835 irq->ifr_receiving = smsc_ircc_is_receiving(
self);
843 smsc_ircc_sir_set_dtr_rts(dev, irq->ifr_dtr, irq->ifr_rts);
853 #if SMSC_IRCC2_C_NET_TIMEOUT
861 static void smsc_ircc_timeout(
struct net_device *dev)
866 IRDA_WARNING(
"%s: transmit timed out, changing speed to: %d\n",
867 dev->
name, self->io.speed);
869 smsc_ircc_sir_start(
self);
870 smsc_ircc_change_speed(
self, self->io.speed);
872 netif_wake_queue(dev);
873 spin_unlock_irqrestore(&self->lock, flags);
895 self = netdev_priv(dev);
898 netif_stop_queue(dev);
904 speed = irda_get_next_speed(skb);
905 if (speed != self->io.speed && speed != -1) {
917 smsc_ircc_sir_wait_hw_transmitter_finish(
self);
918 smsc_ircc_change_speed(
self, speed);
919 spin_unlock_irqrestore(&self->lock, flags);
923 self->new_speed = speed;
927 self->tx_buff.data =
self->tx_buff.head;
931 self->tx_buff.truesize);
933 dev->
stats.tx_bytes +=
self->tx_buff.len;
938 spin_unlock_irqrestore(&self->lock, flags);
951 static void smsc_ircc_set_fir_speed(
struct smsc_ircc_cb *
self,
u32 speed)
956 fir_base =
self->io.fir_base;
958 self->io.speed = speed;
966 IRDA_DEBUG(0,
"%s(), handling baud of 576000\n", __func__);
972 IRDA_DEBUG(0,
"%s(), handling baud of 1152000\n",
979 IRDA_DEBUG(0,
"%s(), handling baud of 4000000\n",
986 register_bank(fir_base, 0);
990 register_bank(fir_base, 1);
993 register_bank(fir_base, 4);
1003 static void smsc_ircc_fir_start(
struct smsc_ircc_cb *
self)
1014 fir_base =
self->io.fir_base;
1024 register_bank(fir_base, 1);
1038 register_bank(fir_base, 0);
1049 static void smsc_ircc_fir_stop(
struct smsc_ircc_cb *
self)
1057 fir_base =
self->io.fir_base;
1058 register_bank(fir_base, 0);
1072 static void smsc_ircc_change_speed(
struct smsc_ircc_cb *
self,
u32 speed)
1075 int last_speed_was_sir;
1077 IRDA_DEBUG(0,
"%s() changing speed to: %d\n", __func__, speed);
1087 self->io.speed = speed;
1088 last_speed_was_sir = 0;
1089 smsc_ircc_fir_start(
self);
1092 if (self->io.speed == 0)
1093 smsc_ircc_sir_start(
self);
1096 if (!last_speed_was_sir) speed =
self->io.speed;
1099 if (self->io.speed != speed)
1100 smsc_ircc_set_transceiver_for_speed(
self, speed);
1102 self->io.speed = speed;
1105 if (!last_speed_was_sir) {
1106 smsc_ircc_fir_stop(
self);
1107 smsc_ircc_sir_start(
self);
1109 smsc_ircc_set_sir_speed(
self, speed);
1111 if (last_speed_was_sir) {
1112 #if SMSC_IRCC2_C_SIR_STOP
1113 smsc_ircc_sir_stop(
self);
1115 smsc_ircc_fir_start(
self);
1117 smsc_ircc_set_fir_speed(
self, speed);
1120 self->tx_buff.len = 10;
1121 self->tx_buff.data =
self->tx_buff.head;
1123 smsc_ircc_dma_xmit(
self, 4000);
1126 smsc_ircc_dma_receive(
self);
1129 netif_wake_queue(dev);
1145 IRDA_DEBUG(0,
"%s(), Setting speed to: %d\n", __func__, speed);
1148 iobase =
self->io.sir_base;
1151 self->io.speed = speed;
1165 fcr |=
self->io.speed < 38400 ?
1180 IRDA_DEBUG(2,
"%s() speed changed to: %d\n", __func__, speed);
1194 unsigned long flags;
1199 self = netdev_priv(dev);
1202 netif_stop_queue(dev);
1208 speed = irda_get_next_speed(skb);
1209 if (speed != self->io.speed && speed != -1) {
1215 smsc_ircc_change_speed(
self, speed);
1216 spin_unlock_irqrestore(&self->lock, flags);
1221 self->new_speed = speed;
1224 skb_copy_from_linear_data(skb, self->tx_buff.
head, skb->
len);
1226 self->tx_buff.len = skb->
len;
1227 self->tx_buff.data =
self->tx_buff.head;
1229 mtt = irda_get_mtt(skb);
1237 bofs = mtt * (
self->io.speed / 1000) / 8000;
1241 smsc_ircc_dma_xmit(
self, bofs);
1244 smsc_ircc_dma_xmit(
self, 0);
1247 spin_unlock_irqrestore(&self->lock, flags);
1259 static void smsc_ircc_dma_xmit(
struct smsc_ircc_cb *
self,
int bofs)
1261 int iobase =
self->io.fir_base;
1267 register_bank(iobase, 0);
1270 register_bank(iobase, 1);
1277 register_bank(iobase, 4);
1289 register_bank(iobase, 1);
1294 irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
1299 register_bank(iobase, 0);
1314 static void smsc_ircc_dma_xmit_complete(
struct smsc_ircc_cb *
self)
1316 int iobase =
self->io.fir_base;
1321 register_bank(iobase, 0);
1324 register_bank(iobase, 1);
1329 register_bank(iobase, 0);
1331 self->netdev->stats.tx_errors++;
1332 self->netdev->stats.tx_fifo_errors++;
1335 register_bank(iobase, 0);
1339 self->netdev->stats.tx_packets++;
1340 self->netdev->stats.tx_bytes +=
self->tx_buff.len;
1344 if (self->new_speed) {
1345 smsc_ircc_change_speed(
self, self->new_speed);
1346 self->new_speed = 0;
1349 netif_wake_queue(self->netdev);
1359 static int smsc_ircc_dma_receive(
struct smsc_ircc_cb *
self)
1361 int iobase =
self->io.fir_base;
1364 register_bank(iobase, 1);
1370 register_bank(iobase, 0);
1374 register_bank(iobase, 1);
1379 self->rx_buff.data =
self->rx_buff.head;
1382 register_bank(iobase, 4);
1387 irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
1391 register_bank(iobase, 1);
1396 register_bank(iobase, 0);
1401 register_bank(iobase, 0);
1414 static void smsc_ircc_dma_receive_complete(
struct smsc_ircc_cb *
self)
1417 int len, msgcnt, lsr;
1418 int iobase =
self->io.fir_base;
1420 register_bank(iobase, 0);
1425 register_bank(iobase, 0);
1428 register_bank(iobase, 0);
1433 IRDA_DEBUG(2,
"%s: dma count = %d\n", __func__,
1440 self->netdev->stats.rx_errors++;
1442 self->netdev->stats.rx_frame_errors++;
1444 self->netdev->stats.rx_crc_errors++;
1446 self->netdev->stats.rx_length_errors++;
1448 self->netdev->stats.rx_length_errors++;
1453 len -=
self->io.speed < 4000000 ? 2 : 4;
1455 if (len < 2 || len > 2050) {
1459 IRDA_DEBUG(2,
"%s: msgcnt = %d, len=%d\n", __func__, msgcnt, len);
1461 skb = dev_alloc_skb(len + 1);
1463 IRDA_WARNING(
"%s(), memory squeeze, dropping frame.\n",
1468 skb_reserve(skb, 1);
1471 self->netdev->stats.rx_packets++;
1472 self->netdev->stats.rx_bytes +=
len;
1474 skb->
dev =
self->netdev;
1475 skb_reset_mac_header(skb);
1486 static void smsc_ircc_sir_receive(
struct smsc_ircc_cb *
self)
1493 iobase =
self->io.sir_base;
1504 if (boguscount++ > 32) {
1505 IRDA_DEBUG(2,
"%s(), breaking!\n", __func__);
1526 spin_lock(&self->lock);
1530 ret = smsc_ircc_interrupt_sir(dev);
1531 goto irq_ret_unlock;
1534 iobase =
self->io.fir_base;
1536 register_bank(iobase, 0);
1539 goto irq_ret_unlock;
1547 IRDA_DEBUG(2,
"%s(), iir = 0x%02x\n", __func__, iir);
1550 if (self->io.direction ==
IO_RECV)
1551 smsc_ircc_dma_receive_complete(
self);
1553 smsc_ircc_dma_xmit_complete(
self);
1555 smsc_ircc_dma_receive(
self);
1564 register_bank(iobase, 0);
1568 spin_unlock(&self->lock);
1588 iobase =
self->io.sir_base;
1597 IRDA_DEBUG(4,
"%s(), iir=%02x, lsr=%02x, iobase=%#x\n",
1598 __func__, iir, lsr, iobase);
1606 smsc_ircc_sir_receive(
self);
1611 smsc_ircc_sir_write_wakeup(
self);
1620 if (boguscount++ > 100)
1637 static int ircc_is_receiving(
struct smsc_ircc_cb *
self)
1646 IRDA_DEBUG(0,
"%s: dma count = %d\n", __func__,
1655 static int smsc_ircc_request_irq(
struct smsc_ircc_cb *
self)
1659 error =
request_irq(self->io.irq, smsc_ircc_interrupt, 0,
1660 self->netdev->name, self->netdev);
1662 IRDA_DEBUG(0,
"%s(), unable to allocate irq=%d, err=%d\n",
1663 __func__, self->io.irq, error);
1668 static void smsc_ircc_start_interrupts(
struct smsc_ircc_cb *
self)
1670 unsigned long flags;
1677 spin_unlock_irqrestore(&self->lock, flags);
1680 static void smsc_ircc_stop_interrupts(
struct smsc_ircc_cb *
self)
1682 int iobase =
self->io.fir_base;
1683 unsigned long flags;
1687 register_bank(iobase, 0);
1692 spin_unlock_irqrestore(&self->lock, flags);
1702 static int smsc_ircc_net_open(
struct net_device *dev)
1710 self = netdev_priv(dev);
1713 if (self->io.suspended) {
1714 IRDA_DEBUG(0,
"%s(), device is suspended\n", __func__);
1720 IRDA_DEBUG(0,
"%s(), unable to allocate irq=%d\n",
1721 __func__, self->io.irq);
1725 smsc_ircc_start_interrupts(
self);
1729 sprintf(hwname,
"SMSC @ 0x%03x", self->io.fir_base);
1735 self->irlap =
irlap_open(dev, &self->qos, hwname);
1742 smsc_ircc_net_close(dev);
1745 __func__, self->io.dma);
1749 netif_start_queue(dev);
1760 static int smsc_ircc_net_close(
struct net_device *dev)
1767 self = netdev_priv(dev);
1771 netif_stop_queue(dev);
1778 smsc_ircc_stop_interrupts(
self);
1781 if (!self->io.suspended)
1794 if (!self->io.suspended) {
1798 if (netif_running(self->netdev)) {
1800 smsc_ircc_stop_interrupts(
self);
1801 free_irq(self->io.irq, self->netdev);
1804 self->io.suspended = 1;
1815 if (self->io.suspended) {
1819 smsc_ircc_init_chip(
self);
1820 if (netif_running(self->netdev)) {
1821 if (smsc_ircc_request_irq(
self)) {
1826 unregister_netdevice(self->netdev);
1829 smsc_ircc_start_interrupts(
self);
1833 self->io.suspended = 0;
1856 smsc_ircc_stop_interrupts(
self);
1859 IRDA_DEBUG(0,
"%s(), releasing 0x%03x\n", __func__,
1864 IRDA_DEBUG(0,
"%s(), releasing 0x%03x\n", __func__,
1869 if (self->tx_buff.head)
1871 self->tx_buff.head, self->tx_buff_dma);
1873 if (self->rx_buff.head)
1875 self->rx_buff.head, self->rx_buff_dma);
1882 static void __exit smsc_ircc_cleanup(
void)
1888 for (i = 0; i < 2; i++) {
1890 smsc_ircc_close(dev_self[i]);
1893 if (pnp_driver_registered)
1905 static void smsc_ircc_sir_start(
struct smsc_ircc_cb *
self)
1908 int fir_base, sir_base;
1916 fir_base =
self->io.fir_base;
1917 sir_base =
self->io.sir_base;
1922 #if SMSC_IRCC2_C_SIR_STOP
1926 register_bank(fir_base, 1);
1941 #if SMSC_IRCC2_C_SIR_STOP
1947 iobase =
self->io.sir_base;
1964 static void smsc_ircc_sir_write_wakeup(
struct smsc_ircc_cb *
self)
1974 iobase =
self->io.sir_base;
1977 if (self->tx_buff.len > 0) {
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;
1992 if (self->new_speed) {
1993 IRDA_DEBUG(5,
"%s(), Changing speed to %d.\n",
1994 __func__, 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;
2000 netif_wake_queue(self->netdev);
2002 self->netdev->stats.tx_packets++;
2004 if (self->io.speed <= 115200) {
2010 fcr |=
self->io.speed < 38400 ?
2027 static int smsc_ircc_sir_write(
int iobase,
int fifo_size,
__u8 *
buf,
int len)
2033 IRDA_WARNING(
"%s(), failed, fifo not empty!\n", __func__);
2038 while (fifo_size-- > 0 && actual < len) {
2052 static int smsc_ircc_is_receiving(
struct smsc_ircc_cb *
self)
2064 static void smsc_ircc_probe_transceiver(
struct smsc_ircc_cb *
self)
2070 for (i = 0; smsc_transceivers[
i].
name !=
NULL; i++)
2071 if (smsc_transceivers[i].probe(self->io.fir_base)) {
2073 smsc_transceivers[i].
name);
2074 self->transceiver= i + 1;
2078 IRDA_MESSAGE(
"No transceiver found. Defaulting to %s\n",
2091 static void smsc_ircc_set_transceiver_for_speed(
struct smsc_ircc_cb *
self,
u32 speed)
2095 trx =
self->transceiver;
2097 smsc_transceivers[trx - 1].
set_for_speed(self->io.fir_base, speed);
2123 static void smsc_ircc_sir_wait_hw_transmitter_finish(
struct smsc_ircc_cb *
self)
2125 int iobase =
self->io.sir_base;
2133 IRDA_DEBUG(0,
"%s(): stuck transmitter\n", __func__);
2143 static int __init smsc_ircc_look_for_chips(
void)
2150 address = possible_addresses;
2160 if (!smsc_superio_flat(fdc_chips_flat, cfg_base, type))
2164 if (!smsc_superio_paged(fdc_chips_paged, cfg_base, type))
2170 if (!smsc_superio_flat(lpc_chips_flat, cfg_base, type))
2174 if (!smsc_superio_paged(lpc_chips_paged, cfg_base, type))
2188 static int __init smsc_superio_flat(
const struct smsc_chip *
chips,
unsigned short cfgbase,
char *type)
2190 unsigned short firbase, sirbase;
2200 mode =
inb(cfgbase + 1);
2208 sirbase =
inb(cfgbase + 1) << 2;
2212 firbase =
inb(cfgbase + 1) << 3;
2222 IRDA_MESSAGE(
"%s(): fir: 0x%02x, sir: 0x%02x, dma: %02d, irq: %d, mode: 0x%02x\n", __func__, firbase, sirbase, dma, irq, mode);
2224 if (firbase && smsc_ircc_open(firbase, sirbase, dma, irq) == 0)
2239 static int __init smsc_superio_paged(
const struct smsc_chip *chips,
unsigned short cfg_base,
char *type)
2241 unsigned short fir_io, sir_io;
2246 if (smsc_ircc_probe(cfg_base, 0x20, chips, type) ==
NULL)
2250 outb(0x07, cfg_base);
2251 outb(0x05, cfg_base + 1);
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);
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);
2266 if (fir_io && smsc_ircc_open(fir_io, sir_io, ircc_dma, ircc_irq) == 0)
2276 static int __init smsc_access(
unsigned short cfg_base,
unsigned char reg)
2280 outb(reg, cfg_base);
2281 return inb(cfg_base) != reg ? -1 : 0;
2297 outb(reg, cfg_base);
2299 xdevid =
inb(cfg_base + 1);
2306 if (smsc_access(cfg_base,0x55))
2312 if (smsc_access(cfg_base, reg))
2315 devid =
inb(cfg_base + 1);
2317 if (devid == 0 || devid == 0xff)
2322 if (smsc_access(cfg_base, reg + 1))
2325 rev =
inb(cfg_base + 1);
2330 if (devid == xdevid)
2335 while (chip->
devid != devid) {
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);
2346 if (chip->
rev > rev) {
2357 static int __init smsc_superio_fdc(
unsigned short cfg_base)
2363 __func__, cfg_base);
2365 if (!smsc_superio_flat(fdc_chips_flat, cfg_base,
"FDC") ||
2366 !smsc_superio_paged(fdc_chips_paged, cfg_base,
"FDC"))
2375 static int __init smsc_superio_lpc(
unsigned short cfg_base)
2381 __func__, cfg_base);
2383 if (!smsc_superio_flat(lpc_chips_flat, cfg_base,
"LPC") ||
2384 !smsc_superio_paged(lpc_chips_paged, cfg_base,
"LPC"))
2407 static struct smsc_ircc_subsystem_configuration subsystem_configurations[]
__initdata = {
2418 .subvendor = 0x103c,
2419 .subdevice = 0x08bc,
2425 .preconfigure = preconfigure_through_82801,
2426 .name =
"HP nx5000 family",
2431 .subvendor = 0x103c,
2432 .subdevice = 0x088c,
2439 .preconfigure = preconfigure_through_82801,
2440 .name =
"HP nc8000 family",
2445 .subvendor = 0x103c,
2446 .subdevice = 0x0890,
2452 .preconfigure = preconfigure_through_82801,
2453 .name =
"HP nc6000 family",
2458 .subvendor = 0x0e11,
2459 .subdevice = 0x0860,
2466 .preconfigure = preconfigure_through_82801,
2467 .name =
"Compaq x1000 family",
2473 .subvendor = 0x1179,
2474 .subdevice = 0xffff,
2480 .preconfigure = preconfigure_through_82801,
2481 .name =
"Toshiba laptop with Intel 82801DB/DBL LPC bridge",
2486 .subvendor = 0x1179,
2487 .subdevice = 0xffff,
2493 .preconfigure = preconfigure_through_82801,
2494 .name =
"Toshiba laptop with Intel 82801CAM ISA bridge",
2500 .subvendor = 0x1179,
2501 .subdevice = 0xffff,
2507 .preconfigure = preconfigure_through_82801,
2508 .name =
"Toshiba laptop with Intel 8281DBM LPC bridge",
2514 .subvendor = 0x1179,
2515 .subdevice = 0xffff,
2521 .preconfigure = preconfigure_through_ali,
2522 .name =
"Toshiba laptop with ALi ISA bridge",
2533 static int __init preconfigure_smsc_chip(
struct
2534 smsc_ircc_subsystem_configuration
2537 unsigned short iobase = conf->cfg_base;
2538 unsigned char tmpbyte;
2542 tmpbyte =
inb(iobase +1);
2544 "Detected Chip id: 0x%02x, setting up registers...\n",
2549 outb(0x00, iobase + 1);
2551 outb( (conf->sir_io >> 2), iobase + 1);
2552 tmpbyte =
inb(iobase + 1);
2553 if (tmpbyte != (conf->sir_io >> 2) ) {
2554 IRDA_WARNING(
"ERROR: could not configure SIR ioport.\n");
2561 tmpbyte =
inb(iobase + 1);
2564 outb(tmpbyte, iobase + 1);
2566 if (tmpbyte != conf->fir_irq) {
2567 IRDA_WARNING(
"ERROR: could not configure FIR IRQ channel.\n");
2573 outb((conf->fir_io >> 3), iobase + 1);
2574 tmpbyte =
inb(iobase + 1);
2575 if (tmpbyte != (conf->fir_io >> 3) ) {
2576 IRDA_WARNING(
"ERROR: could not configure FIR I/O port.\n");
2585 IRDA_WARNING(
"ERROR: could not configure FIR DMA channel.\n");
2590 tmpbyte =
inb(iobase + 1);
2593 outb(tmpbyte, iobase + 1);
2596 tmpbyte =
inb(iobase + 1);
2601 tmpbyte =
inb(iobase + 1);
2602 outb(tmpbyte | 0x40, iobase + 1);
2605 tmpbyte =
inb(iobase + 1);
2609 tmpbyte =
inb(iobase + 1);
2620 #define PIRQ_A_D_ROUT 0x60
2621 #define SIRQ_CNTL 0x64
2622 #define PIRQ_E_H_ROUT 0x68
2623 #define PCI_DMA_C 0x90
2625 #define COM_DEC 0xe0
2626 #define GEN1_DEC 0xe4
2628 #define GEN2_DEC 0xec
2634 static int __init preconfigure_through_82801(
struct pci_dev *dev,
2636 smsc_ircc_subsystem_configuration
2639 unsigned short tmpword;
2640 unsigned char tmpbyte;
2642 IRDA_MESSAGE(
"Setting up Intel 82801 controller and SMSC device\n");
2661 pci_read_config_byte(dev, COM_DEC, &tmpbyte);
2663 switch(conf->sir_io) {
2691 IRDA_DEBUG(1,
"COM_DEC (write): 0x%02x\n", tmpbyte);
2692 pci_write_config_byte(dev, COM_DEC, tmpbyte);
2695 pci_read_config_word(dev, LPC_EN, &tmpword);
2699 switch(conf->cfg_base) {
2719 IRDA_DEBUG(1,
"LPC_EN (write): 0x%04x\n", tmpword);
2720 pci_write_config_word(dev, LPC_EN, tmpword);
2738 pci_read_config_word(dev, PCI_DMA_C, &tmpword);
2739 switch(conf->fir_dma) {
2764 IRDA_DEBUG(1,
"PCI_DMA_C (write): 0x%04x\n", tmpword);
2765 pci_write_config_word(dev, PCI_DMA_C, tmpword);
2773 tmpword = conf->fir_io & 0xfff8;
2775 IRDA_DEBUG(1,
"GEN2_DEC (write): 0x%04x\n", tmpword);
2776 pci_write_config_word(dev, GEN2_DEC, tmpword);
2779 return preconfigure_smsc_chip(conf);
2787 static void __init preconfigure_ali_port(
struct pci_dev *dev,
2788 unsigned short port)
2793 unsigned char tmpbyte;
2814 IRDA_ERROR(
"Failed to configure unsupported port on ALi 1533 bridge: 0x%04x\n", port);
2818 pci_read_config_byte(dev, reg, &tmpbyte);
2821 pci_write_config_byte(dev, reg, tmpbyte);
2822 IRDA_MESSAGE(
"Activated ALi 1533 ISA bridge port 0x%04x.\n", port);
2825 static int __init preconfigure_through_ali(
struct pci_dev *dev,
2827 smsc_ircc_subsystem_configuration
2831 preconfigure_ali_port(dev, conf->sir_io);
2832 preconfigure_ali_port(dev, conf->fir_io);
2835 return preconfigure_smsc_chip(conf);
2838 static int __init smsc_ircc_preconfigure_subsystems(
unsigned short ircc_cfg,
2839 unsigned short ircc_fir,
2840 unsigned short ircc_sir,
2841 unsigned char ircc_dma,
2842 unsigned char ircc_irq)
2845 unsigned short ss_vendor = 0x0000;
2846 unsigned short ss_device = 0x0000;
2850 struct smsc_ircc_subsystem_configuration *conf;
2862 conf = subsystem_configurations;
2863 for( ; conf->subvendor; conf++) {
2864 if(conf->vendor == dev->
vendor &&
2865 conf->device == dev->
device &&
2866 conf->subvendor == ss_vendor &&
2868 (conf->subdevice == ss_device ||
2869 conf->subdevice == 0xffff)) {
2870 struct smsc_ircc_subsystem_configuration
2874 sizeof(
struct smsc_ircc_subsystem_configuration));
2881 tmpconf.cfg_base = ircc_cfg;
2883 tmpconf.fir_io = ircc_fir;
2885 tmpconf.sir_io = ircc_sir;
2887 tmpconf.fir_dma = ircc_dma;
2889 tmpconf.fir_irq = ircc_irq;
2891 IRDA_MESSAGE(
"Detected unconfigured %s SMSC IrDA chip, pre-configuring device.\n", conf->name);
2892 if (conf->preconfigure)
2893 ret = conf->preconfigure(dev, &tmpconf);
2902 #endif // CONFIG_PCI
2918 static void smsc_ircc_set_transceiver_smsc_ircc_atc(
int fir_base,
u32 speed)
2920 unsigned long jiffies_now, jiffies_timeout;
2927 register_bank(fir_base, 4);
2947 static int smsc_ircc_probe_transceiver_smsc_ircc_atc(
int fir_base)
2959 static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(
int fir_base,
u32 speed)
2973 register_bank(fir_base, 0);
2984 static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(
int fir_base)
2996 static void smsc_ircc_set_transceiver_toshiba_sat1800(
int fir_base,
u32 speed)
3012 register_bank(fir_base, 0);
3023 static int smsc_ircc_probe_transceiver_toshiba_sat1800(
int fir_base)