aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/8250_pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serial/8250_pci.c')
-rw-r--r--drivers/tty/serial/8250_pci.c183
1 files changed, 182 insertions, 1 deletions
diff --git a/drivers/tty/serial/8250_pci.c b/drivers/tty/serial/8250_pci.c
index cf35e0dc508..6b887d90a20 100644
--- a/drivers/tty/serial/8250_pci.c
+++ b/drivers/tty/serial/8250_pci.c
@@ -39,6 +39,7 @@ struct pci_serial_quirk {
39 u32 device; 39 u32 device;
40 u32 subvendor; 40 u32 subvendor;
41 u32 subdevice; 41 u32 subdevice;
42 int (*probe)(struct pci_dev *dev);
42 int (*init)(struct pci_dev *dev); 43 int (*init)(struct pci_dev *dev);
43 int (*setup)(struct serial_private *, 44 int (*setup)(struct serial_private *,
44 const struct pciserial_board *, 45 const struct pciserial_board *,
@@ -56,6 +57,9 @@ struct serial_private {
56 int line[0]; 57 int line[0];
57}; 58};
58 59
60static int pci_default_setup(struct serial_private*,
61 const struct pciserial_board*, struct uart_port*, int);
62
59static void moan_device(const char *str, struct pci_dev *dev) 63static void moan_device(const char *str, struct pci_dev *dev)
60{ 64{
61 printk(KERN_WARNING 65 printk(KERN_WARNING
@@ -571,6 +575,28 @@ static const struct timedia_struct {
571 { 8, timedia_eight_port } 575 { 8, timedia_eight_port }
572}; 576};
573 577
578/*
579 * There are nearly 70 different Timedia/SUNIX PCI serial devices. Instead of
580 * listing them individually, this driver merely grabs them all with
581 * PCI_ANY_ID. Some of these devices, however, also feature a parallel port,
582 * and should be left free to be claimed by parport_serial instead.
583 */
584static int pci_timedia_probe(struct pci_dev *dev)
585{
586 /*
587 * Check the third digit of the subdevice ID
588 * (0,2,3,5,6: serial only -- 7,8,9: serial + parallel)
589 */
590 if ((dev->subsystem_device & 0x00f0) >= 0x70) {
591 dev_info(&dev->dev,
592 "ignoring Timedia subdevice %04x for parport_serial\n",
593 dev->subsystem_device);
594 return -ENODEV;
595 }
596
597 return 0;
598}
599
574static int pci_timedia_init(struct pci_dev *dev) 600static int pci_timedia_init(struct pci_dev *dev)
575{ 601{
576 const unsigned short *ids; 602 const unsigned short *ids;
@@ -752,6 +778,62 @@ pci_ni8430_setup(struct serial_private *priv,
752 return setup_port(priv, port, bar, offset, board->reg_shift); 778 return setup_port(priv, port, bar, offset, board->reg_shift);
753} 779}
754 780
781static int pci_netmos_9900_setup(struct serial_private *priv,
782 const struct pciserial_board *board,
783 struct uart_port *port, int idx)
784{
785 unsigned int bar;
786
787 if ((priv->dev->subsystem_device & 0xff00) == 0x3000) {
788 /* netmos apparently orders BARs by datasheet layout, so serial
789 * ports get BARs 0 and 3 (or 1 and 4 for memmapped)
790 */
791 bar = 3 * idx;
792
793 return setup_port(priv, port, bar, 0, board->reg_shift);
794 } else {
795 return pci_default_setup(priv, board, port, idx);
796 }
797}
798
799/* the 99xx series comes with a range of device IDs and a variety
800 * of capabilities:
801 *
802 * 9900 has varying capabilities and can cascade to sub-controllers
803 * (cascading should be purely internal)
804 * 9904 is hardwired with 4 serial ports
805 * 9912 and 9922 are hardwired with 2 serial ports
806 */
807static int pci_netmos_9900_numports(struct pci_dev *dev)
808{
809 unsigned int c = dev->class;
810 unsigned int pi;
811 unsigned short sub_serports;
812
813 pi = (c & 0xff);
814
815 if (pi == 2) {
816 return 1;
817 } else if ((pi == 0) &&
818 (dev->device == PCI_DEVICE_ID_NETMOS_9900)) {
819 /* two possibilities: 0x30ps encodes number of parallel and
820 * serial ports, or 0x1000 indicates *something*. This is not
821 * immediately obvious, since the 2s1p+4s configuration seems
822 * to offer all functionality on functions 0..2, while still
823 * advertising the same function 3 as the 4s+2s1p config.
824 */
825 sub_serports = dev->subsystem_device & 0xf;
826 if (sub_serports > 0) {
827 return sub_serports;
828 } else {
829 printk(KERN_NOTICE "NetMos/Mostech serial driver ignoring port on ambiguous config.\n");
830 return 0;
831 }
832 }
833
834 moan_device("unknown NetMos/Mostech program interface", dev);
835 return 0;
836}
755 837
756static int pci_netmos_init(struct pci_dev *dev) 838static int pci_netmos_init(struct pci_dev *dev)
757{ 839{
@@ -761,12 +843,28 @@ static int pci_netmos_init(struct pci_dev *dev)
761 if ((dev->device == PCI_DEVICE_ID_NETMOS_9901) || 843 if ((dev->device == PCI_DEVICE_ID_NETMOS_9901) ||
762 (dev->device == PCI_DEVICE_ID_NETMOS_9865)) 844 (dev->device == PCI_DEVICE_ID_NETMOS_9865))
763 return 0; 845 return 0;
846
764 if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM && 847 if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
765 dev->subsystem_device == 0x0299) 848 dev->subsystem_device == 0x0299)
766 return 0; 849 return 0;
767 850
851 switch (dev->device) { /* FALLTHROUGH on all */
852 case PCI_DEVICE_ID_NETMOS_9904:
853 case PCI_DEVICE_ID_NETMOS_9912:
854 case PCI_DEVICE_ID_NETMOS_9922:
855 case PCI_DEVICE_ID_NETMOS_9900:
856 num_serial = pci_netmos_9900_numports(dev);
857 break;
858
859 default:
860 if (num_serial == 0 ) {
861 moan_device("unknown NetMos/Mostech device", dev);
862 }
863 }
864
768 if (num_serial == 0) 865 if (num_serial == 0)
769 return -ENODEV; 866 return -ENODEV;
867
770 return num_serial; 868 return num_serial;
771} 869}
772 870
@@ -1396,6 +1494,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1396 .device = PCI_DEVICE_ID_TIMEDIA_1889, 1494 .device = PCI_DEVICE_ID_TIMEDIA_1889,
1397 .subvendor = PCI_VENDOR_ID_TIMEDIA, 1495 .subvendor = PCI_VENDOR_ID_TIMEDIA,
1398 .subdevice = PCI_ANY_ID, 1496 .subdevice = PCI_ANY_ID,
1497 .probe = pci_timedia_probe,
1399 .init = pci_timedia_init, 1498 .init = pci_timedia_init,
1400 .setup = pci_timedia_setup, 1499 .setup = pci_timedia_setup,
1401 }, 1500 },
@@ -1426,7 +1525,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1426 .subvendor = PCI_ANY_ID, 1525 .subvendor = PCI_ANY_ID,
1427 .subdevice = PCI_ANY_ID, 1526 .subdevice = PCI_ANY_ID,
1428 .init = pci_netmos_init, 1527 .init = pci_netmos_init,
1429 .setup = pci_default_setup, 1528 .setup = pci_netmos_9900_setup,
1430 }, 1529 },
1431 /* 1530 /*
1432 * For Oxford Semiconductor Tornado based devices 1531 * For Oxford Semiconductor Tornado based devices
@@ -1703,6 +1802,7 @@ enum pci_board_num_t {
1703 pbn_ADDIDATA_PCIe_8_3906250, 1802 pbn_ADDIDATA_PCIe_8_3906250,
1704 pbn_ce4100_1_115200, 1803 pbn_ce4100_1_115200,
1705 pbn_omegapci, 1804 pbn_omegapci,
1805 pbn_NETMOS9900_2s_115200,
1706}; 1806};
1707 1807
1708/* 1808/*
@@ -2404,6 +2504,11 @@ static struct pciserial_board pci_boards[] __devinitdata = {
2404 .base_baud = 115200, 2504 .base_baud = 115200,
2405 .uart_offset = 0x200, 2505 .uart_offset = 0x200,
2406 }, 2506 },
2507 [pbn_NETMOS9900_2s_115200] = {
2508 .flags = FL_BASE0,
2509 .num_ports = 2,
2510 .base_baud = 115200,
2511 },
2407}; 2512};
2408 2513
2409static const struct pci_device_id softmodem_blacklist[] = { 2514static const struct pci_device_id softmodem_blacklist[] = {
@@ -2640,11 +2745,19 @@ EXPORT_SYMBOL_GPL(pciserial_resume_ports);
2640static int __devinit 2745static int __devinit
2641pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent) 2746pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
2642{ 2747{
2748 struct pci_serial_quirk *quirk;
2643 struct serial_private *priv; 2749 struct serial_private *priv;
2644 const struct pciserial_board *board; 2750 const struct pciserial_board *board;
2645 struct pciserial_board tmp; 2751 struct pciserial_board tmp;
2646 int rc; 2752 int rc;
2647 2753
2754 quirk = find_quirk(dev);
2755 if (quirk->probe) {
2756 rc = quirk->probe(dev);
2757 if (rc)
2758 return rc;
2759 }
2760
2648 if (ent->driver_data >= ARRAY_SIZE(pci_boards)) { 2761 if (ent->driver_data >= ARRAY_SIZE(pci_boards)) {
2649 printk(KERN_ERR "pci_init_one: invalid driver_data: %ld\n", 2762 printk(KERN_ERR "pci_init_one: invalid driver_data: %ld\n",
2650 ent->driver_data); 2763 ent->driver_data);
@@ -2654,6 +2767,7 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
2654 board = &pci_boards[ent->driver_data]; 2767 board = &pci_boards[ent->driver_data];
2655 2768
2656 rc = pci_enable_device(dev); 2769 rc = pci_enable_device(dev);
2770 pci_save_state(dev);
2657 if (rc) 2771 if (rc)
2658 return rc; 2772 return rc;
2659 2773
@@ -3885,6 +3999,27 @@ static struct pci_device_id serial_pci_tbl[] = {
3885 0xA000, 0x1000, 3999 0xA000, 0x1000,
3886 0, 0, pbn_b0_1_115200 }, 4000 0, 0, pbn_b0_1_115200 },
3887 4001
4002 /* the 9901 is a rebranded 9912 */
4003 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9912,
4004 0xA000, 0x1000,
4005 0, 0, pbn_b0_1_115200 },
4006
4007 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9922,
4008 0xA000, 0x1000,
4009 0, 0, pbn_b0_1_115200 },
4010
4011 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9904,
4012 0xA000, 0x1000,
4013 0, 0, pbn_b0_1_115200 },
4014
4015 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9900,
4016 0xA000, 0x1000,
4017 0, 0, pbn_b0_1_115200 },
4018
4019 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9900,
4020 0xA000, 0x3002,
4021 0, 0, pbn_NETMOS9900_2s_115200 },
4022
3888 /* 4023 /*
3889 * Best Connectivity PCI Multi I/O cards 4024 * Best Connectivity PCI Multi I/O cards
3890 */ 4025 */
@@ -3927,6 +4062,51 @@ static struct pci_device_id serial_pci_tbl[] = {
3927 { 0, } 4062 { 0, }
3928}; 4063};
3929 4064
4065static pci_ers_result_t serial8250_io_error_detected(struct pci_dev *dev,
4066 pci_channel_state_t state)
4067{
4068 struct serial_private *priv = pci_get_drvdata(dev);
4069
4070 if (state == pci_channel_io_perm_failure)
4071 return PCI_ERS_RESULT_DISCONNECT;
4072
4073 if (priv)
4074 pciserial_suspend_ports(priv);
4075
4076 pci_disable_device(dev);
4077
4078 return PCI_ERS_RESULT_NEED_RESET;
4079}
4080
4081static pci_ers_result_t serial8250_io_slot_reset(struct pci_dev *dev)
4082{
4083 int rc;
4084
4085 rc = pci_enable_device(dev);
4086
4087 if (rc)
4088 return PCI_ERS_RESULT_DISCONNECT;
4089
4090 pci_restore_state(dev);
4091 pci_save_state(dev);
4092
4093 return PCI_ERS_RESULT_RECOVERED;
4094}
4095
4096static void serial8250_io_resume(struct pci_dev *dev)
4097{
4098 struct serial_private *priv = pci_get_drvdata(dev);
4099
4100 if (priv)
4101 pciserial_resume_ports(priv);
4102}
4103
4104static struct pci_error_handlers serial8250_err_handler = {
4105 .error_detected = serial8250_io_error_detected,
4106 .slot_reset = serial8250_io_slot_reset,
4107 .resume = serial8250_io_resume,
4108};
4109
3930static struct pci_driver serial_pci_driver = { 4110static struct pci_driver serial_pci_driver = {
3931 .name = "serial", 4111 .name = "serial",
3932 .probe = pciserial_init_one, 4112 .probe = pciserial_init_one,
@@ -3936,6 +4116,7 @@ static struct pci_driver serial_pci_driver = {
3936 .resume = pciserial_resume_one, 4116 .resume = pciserial_resume_one,
3937#endif 4117#endif
3938 .id_table = serial_pci_tbl, 4118 .id_table = serial_pci_tbl,
4119 .err_handler = &serial8250_err_handler,
3939}; 4120};
3940 4121
3941static int __init serial8250_pci_init(void) 4122static int __init serial8250_pci_init(void)