]> git.hungrycats.org Git - linux/commitdiff
[SERIAL] Add PCI serial power management support.
authorRussell King <rmk@flint.arm.linux.org.uk>
Tue, 11 Mar 2003 22:24:53 +0000 (22:24 +0000)
committerLinus Torvalds <torvalds@home.transmeta.com>
Tue, 11 Mar 2003 22:24:53 +0000 (22:24 +0000)
drivers/serial/8250.c
drivers/serial/8250.h
drivers/serial/8250_pci.c

index be094804cf7980ce3d356a613c8e308fbada212e..3b719f893e558ba18070f207723518b340ea6f7d 100644 (file)
@@ -93,13 +93,15 @@ unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
 #ifdef CONFIG_SERIAL_8250_MULTIPORT
 #define CONFIG_SERIAL_MULTIPORT 1
 #endif
+#ifdef CONFIG_SERIAL_8250_MANY_PORTS
+#define CONFIG_SERIAL_MANY_PORTS 1
+#endif
 
 /*
  * HUB6 is always on.  This will be removed once the header
  * files have been cleaned.
  */
 #define CONFIG_HUB6 1
-#define CONFIG_SERIAL_MANY_PORTS 1
 
 #include <asm/serial.h>
 
@@ -2094,6 +2096,28 @@ void serial8250_get_irq_map(unsigned int *map)
        }
 }
 
+/**
+ *     serial8250_suspend_port - suspend one serial port
+ *     @line: serial line number
+ *
+ *     Suspend one serial port.
+ */
+void serial8250_suspend_port(int line, u32 level)
+{
+       uart_suspend_port(&serial8250_reg, &serial8250_ports[line].port, level);
+}
+
+/**
+ *     serial8250_resume_port - resume one serial port
+ *     @line: serial line number
+ *
+ *     Resume one serial port.
+ */
+void serial8250_resume_port(int line, u32 level)
+{
+       uart_resume_port(&serial8250_reg, &serial8250_ports[line].port, level);
+}
+
 static int __init serial8250_init(void)
 {
        int ret, i;
@@ -2127,6 +2151,8 @@ module_exit(serial8250_exit);
 EXPORT_SYMBOL(register_serial);
 EXPORT_SYMBOL(unregister_serial);
 EXPORT_SYMBOL(serial8250_get_irq_map);
+EXPORT_SYMBOL(serial8250_suspend_port);
+EXPORT_SYMBOL(serial8250_resume_port);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Generic 8250/16x50 serial driver $Revision: 1.90 $");
index 030116e6ebf6960c275922004659f9c01b3c6ed3..cc206f9476acf723ab95257e8a7c4aed2e2e1bbb 100644 (file)
@@ -27,6 +27,8 @@ struct serial8250_probe {
 int serial8250_register_probe(struct serial8250_probe *probe);
 void serial8250_unregister_probe(struct serial8250_probe *probe);
 void serial8250_get_irq_map(unsigned int *map);
+void serial8250_suspend_port(int line, u32 level);
+void serial8250_resume_port(int line, u32 level);
 
 struct old_serial_port {
        unsigned int uart;
index b0711e53f471974d1a62e7ee11a9d31b9cbd78af..1123ebd9fe30bd12e6a480a2ca9ccb4602cc55ca 100644 (file)
@@ -1592,6 +1592,53 @@ static void __devexit pciserial_remove_one(struct pci_dev *dev)
        }
 }
 
+static int pciserial_save_state_one(struct pci_dev *dev, u32 state)
+{
+       struct serial_private *priv = pci_get_drvdata(dev);
+
+       if (priv) {
+               int i;
+
+               for (i = 0; i < priv->nr; i++)
+                       serial8250_suspend_port(priv->line[i], SUSPEND_SAVE_STATE);
+       }
+       return 0;
+}
+
+static int pciserial_suspend_one(struct pci_dev *dev, u32 state)
+{
+       struct serial_private *priv = pci_get_drvdata(dev);
+
+       if (priv) {
+               int i;
+
+               for (i = 0; i < priv->nr; i++)
+                       serial8250_suspend_port(priv->line[i], SUSPEND_POWER_DOWN);
+       }
+       return 0;
+}
+
+static int pciserial_resume_one(struct pci_dev *dev)
+{
+       struct serial_private *priv = pci_get_drvdata(dev);
+
+       if (priv) {
+               int i;
+
+               /*
+                * Ensure that the board is correctly configured.
+                */
+               if (priv->quirk->init)
+                       priv->quirk->init(dev);
+
+               for (i = 0; i < priv->nr; i++) {
+                       serial8250_resume_port(priv->line[i], RESUME_POWER_ON);
+                       serial8250_resume_port(priv->line[i], RESUME_RESTORE_STATE);
+               }
+       }
+       return 0;
+}
+
 static struct pci_device_id serial_pci_tbl[] __devinitdata = {
        {       PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V960,
                PCI_SUBVENDOR_ID_CONNECT_TECH,
@@ -1986,6 +2033,9 @@ static struct pci_driver serial_pci_driver = {
        .name           = "serial",
        .probe          = pciserial_init_one,
        .remove         = __devexit_p(pciserial_remove_one),
+       .save_state     = pciserial_save_state_one,
+       .suspend        = pciserial_suspend_one,
+       .resume         = pciserial_resume_one,
        .id_table       = serial_pci_tbl,
        .driver = {
                .devclass = &tty_devclass,