diff options
Diffstat (limited to 'drivers/serial/8250.c')
-rw-r--r-- | drivers/serial/8250.c | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 24110f6f61e0..167c4a6ccbc3 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/platform_device.h> | 32 | #include <linux/platform_device.h> |
33 | #include <linux/tty.h> | 33 | #include <linux/tty.h> |
34 | #include <linux/ratelimit.h> | ||
34 | #include <linux/tty_flip.h> | 35 | #include <linux/tty_flip.h> |
35 | #include <linux/serial_reg.h> | 36 | #include <linux/serial_reg.h> |
36 | #include <linux/serial_core.h> | 37 | #include <linux/serial_core.h> |
@@ -154,12 +155,6 @@ struct uart_8250_port { | |||
154 | unsigned char lsr_saved_flags; | 155 | unsigned char lsr_saved_flags; |
155 | #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA | 156 | #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA |
156 | unsigned char msr_saved_flags; | 157 | unsigned char msr_saved_flags; |
157 | |||
158 | /* | ||
159 | * We provide a per-port pm hook. | ||
160 | */ | ||
161 | void (*pm)(struct uart_port *port, | ||
162 | unsigned int state, unsigned int old); | ||
163 | }; | 158 | }; |
164 | 159 | ||
165 | struct irq_info { | 160 | struct irq_info { |
@@ -1606,8 +1601,8 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id) | |||
1606 | 1601 | ||
1607 | if (l == i->head && pass_counter++ > PASS_LIMIT) { | 1602 | if (l == i->head && pass_counter++ > PASS_LIMIT) { |
1608 | /* If we hit this, we're dead. */ | 1603 | /* If we hit this, we're dead. */ |
1609 | printk(KERN_ERR "serial8250: too much work for " | 1604 | printk_ratelimited(KERN_ERR |
1610 | "irq%d\n", irq); | 1605 | "serial8250: too much work for irq%d\n", irq); |
1611 | break; | 1606 | break; |
1612 | } | 1607 | } |
1613 | } while (l != end); | 1608 | } while (l != end); |
@@ -1722,12 +1717,6 @@ static void serial_unlink_irq_chain(struct uart_8250_port *up) | |||
1722 | mutex_unlock(&hash_mutex); | 1717 | mutex_unlock(&hash_mutex); |
1723 | } | 1718 | } |
1724 | 1719 | ||
1725 | /* Base timer interval for polling */ | ||
1726 | static inline int poll_timeout(int timeout) | ||
1727 | { | ||
1728 | return timeout > 6 ? (timeout / 2 - 2) : 1; | ||
1729 | } | ||
1730 | |||
1731 | /* | 1720 | /* |
1732 | * This function is used to handle ports that do not have an | 1721 | * This function is used to handle ports that do not have an |
1733 | * interrupt. This doesn't work very well for 16450's, but gives | 1722 | * interrupt. This doesn't work very well for 16450's, but gives |
@@ -1742,7 +1731,7 @@ static void serial8250_timeout(unsigned long data) | |||
1742 | iir = serial_in(up, UART_IIR); | 1731 | iir = serial_in(up, UART_IIR); |
1743 | if (!(iir & UART_IIR_NO_INT)) | 1732 | if (!(iir & UART_IIR_NO_INT)) |
1744 | serial8250_handle_port(up); | 1733 | serial8250_handle_port(up); |
1745 | mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout)); | 1734 | mod_timer(&up->timer, jiffies + uart_poll_timeout(&up->port)); |
1746 | } | 1735 | } |
1747 | 1736 | ||
1748 | static void serial8250_backup_timeout(unsigned long data) | 1737 | static void serial8250_backup_timeout(unsigned long data) |
@@ -1787,7 +1776,7 @@ static void serial8250_backup_timeout(unsigned long data) | |||
1787 | 1776 | ||
1788 | /* Standard timer interval plus 0.2s to keep the port running */ | 1777 | /* Standard timer interval plus 0.2s to keep the port running */ |
1789 | mod_timer(&up->timer, | 1778 | mod_timer(&up->timer, |
1790 | jiffies + poll_timeout(up->port.timeout) + HZ / 5); | 1779 | jiffies + uart_poll_timeout(&up->port) + HZ / 5); |
1791 | } | 1780 | } |
1792 | 1781 | ||
1793 | static unsigned int serial8250_tx_empty(struct uart_port *port) | 1782 | static unsigned int serial8250_tx_empty(struct uart_port *port) |
@@ -1867,15 +1856,17 @@ static void wait_for_xmitr(struct uart_8250_port *up, int bits) | |||
1867 | unsigned int status, tmout = 10000; | 1856 | unsigned int status, tmout = 10000; |
1868 | 1857 | ||
1869 | /* Wait up to 10ms for the character(s) to be sent. */ | 1858 | /* Wait up to 10ms for the character(s) to be sent. */ |
1870 | do { | 1859 | for (;;) { |
1871 | status = serial_in(up, UART_LSR); | 1860 | status = serial_in(up, UART_LSR); |
1872 | 1861 | ||
1873 | up->lsr_saved_flags |= status & LSR_SAVE_FLAGS; | 1862 | up->lsr_saved_flags |= status & LSR_SAVE_FLAGS; |
1874 | 1863 | ||
1864 | if ((status & bits) == bits) | ||
1865 | break; | ||
1875 | if (--tmout == 0) | 1866 | if (--tmout == 0) |
1876 | break; | 1867 | break; |
1877 | udelay(1); | 1868 | udelay(1); |
1878 | } while ((status & bits) != bits); | 1869 | } |
1879 | 1870 | ||
1880 | /* Wait up to 1s for flow control if necessary */ | 1871 | /* Wait up to 1s for flow control if necessary */ |
1881 | if (up->port.flags & UPF_CONS_FLOW) { | 1872 | if (up->port.flags & UPF_CONS_FLOW) { |
@@ -2069,7 +2060,7 @@ static int serial8250_startup(struct uart_port *port) | |||
2069 | up->timer.function = serial8250_backup_timeout; | 2060 | up->timer.function = serial8250_backup_timeout; |
2070 | up->timer.data = (unsigned long)up; | 2061 | up->timer.data = (unsigned long)up; |
2071 | mod_timer(&up->timer, jiffies + | 2062 | mod_timer(&up->timer, jiffies + |
2072 | poll_timeout(up->port.timeout) + HZ / 5); | 2063 | uart_poll_timeout(port) + HZ / 5); |
2073 | } | 2064 | } |
2074 | 2065 | ||
2075 | /* | 2066 | /* |
@@ -2079,7 +2070,7 @@ static int serial8250_startup(struct uart_port *port) | |||
2079 | */ | 2070 | */ |
2080 | if (!is_real_interrupt(up->port.irq)) { | 2071 | if (!is_real_interrupt(up->port.irq)) { |
2081 | up->timer.data = (unsigned long)up; | 2072 | up->timer.data = (unsigned long)up; |
2082 | mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout)); | 2073 | mod_timer(&up->timer, jiffies + uart_poll_timeout(port)); |
2083 | } else { | 2074 | } else { |
2084 | retval = serial_link_irq_chain(up); | 2075 | retval = serial_link_irq_chain(up); |
2085 | if (retval) | 2076 | if (retval) |
@@ -2440,16 +2431,24 @@ serial8250_set_ldisc(struct uart_port *port, int new) | |||
2440 | port->flags &= ~UPF_HARDPPS_CD; | 2431 | port->flags &= ~UPF_HARDPPS_CD; |
2441 | } | 2432 | } |
2442 | 2433 | ||
2443 | static void | 2434 | |
2444 | serial8250_pm(struct uart_port *port, unsigned int state, | 2435 | void serial8250_do_pm(struct uart_port *port, unsigned int state, |
2445 | unsigned int oldstate) | 2436 | unsigned int oldstate) |
2446 | { | 2437 | { |
2447 | struct uart_8250_port *p = (struct uart_8250_port *)port; | 2438 | struct uart_8250_port *p = (struct uart_8250_port *)port; |
2448 | 2439 | ||
2449 | serial8250_set_sleep(p, state != 0); | 2440 | serial8250_set_sleep(p, state != 0); |
2441 | } | ||
2442 | EXPORT_SYMBOL(serial8250_do_pm); | ||
2450 | 2443 | ||
2451 | if (p->pm) | 2444 | static void |
2452 | p->pm(port, state, oldstate); | 2445 | serial8250_pm(struct uart_port *port, unsigned int state, |
2446 | unsigned int oldstate) | ||
2447 | { | ||
2448 | if (port->pm) | ||
2449 | port->pm(port, state, oldstate); | ||
2450 | else | ||
2451 | serial8250_do_pm(port, state, oldstate); | ||
2453 | } | 2452 | } |
2454 | 2453 | ||
2455 | static unsigned int serial8250_port_size(struct uart_8250_port *pt) | 2454 | static unsigned int serial8250_port_size(struct uart_8250_port *pt) |
@@ -2674,6 +2673,16 @@ static struct uart_ops serial8250_pops = { | |||
2674 | 2673 | ||
2675 | static struct uart_8250_port serial8250_ports[UART_NR]; | 2674 | static struct uart_8250_port serial8250_ports[UART_NR]; |
2676 | 2675 | ||
2676 | static void (*serial8250_isa_config)(int port, struct uart_port *up, | ||
2677 | unsigned short *capabilities); | ||
2678 | |||
2679 | void serial8250_set_isa_configurator( | ||
2680 | void (*v)(int port, struct uart_port *up, unsigned short *capabilities)) | ||
2681 | { | ||
2682 | serial8250_isa_config = v; | ||
2683 | } | ||
2684 | EXPORT_SYMBOL(serial8250_set_isa_configurator); | ||
2685 | |||
2677 | static void __init serial8250_isa_init_ports(void) | 2686 | static void __init serial8250_isa_init_ports(void) |
2678 | { | 2687 | { |
2679 | struct uart_8250_port *up; | 2688 | struct uart_8250_port *up; |
@@ -2719,6 +2728,9 @@ static void __init serial8250_isa_init_ports(void) | |||
2719 | up->port.regshift = old_serial_port[i].iomem_reg_shift; | 2728 | up->port.regshift = old_serial_port[i].iomem_reg_shift; |
2720 | set_io_from_upio(&up->port); | 2729 | set_io_from_upio(&up->port); |
2721 | up->port.irqflags |= irqflag; | 2730 | up->port.irqflags |= irqflag; |
2731 | if (serial8250_isa_config != NULL) | ||
2732 | serial8250_isa_config(i, &up->port, &up->capabilities); | ||
2733 | |||
2722 | } | 2734 | } |
2723 | } | 2735 | } |
2724 | 2736 | ||
@@ -3010,6 +3022,7 @@ static int __devinit serial8250_probe(struct platform_device *dev) | |||
3010 | port.serial_in = p->serial_in; | 3022 | port.serial_in = p->serial_in; |
3011 | port.serial_out = p->serial_out; | 3023 | port.serial_out = p->serial_out; |
3012 | port.set_termios = p->set_termios; | 3024 | port.set_termios = p->set_termios; |
3025 | port.pm = p->pm; | ||
3013 | port.dev = &dev->dev; | 3026 | port.dev = &dev->dev; |
3014 | port.irqflags |= irqflag; | 3027 | port.irqflags |= irqflag; |
3015 | ret = serial8250_register_port(&port); | 3028 | ret = serial8250_register_port(&port); |
@@ -3176,6 +3189,12 @@ int serial8250_register_port(struct uart_port *port) | |||
3176 | /* Possibly override set_termios call */ | 3189 | /* Possibly override set_termios call */ |
3177 | if (port->set_termios) | 3190 | if (port->set_termios) |
3178 | uart->port.set_termios = port->set_termios; | 3191 | uart->port.set_termios = port->set_termios; |
3192 | if (port->pm) | ||
3193 | uart->port.pm = port->pm; | ||
3194 | |||
3195 | if (serial8250_isa_config != NULL) | ||
3196 | serial8250_isa_config(0, &uart->port, | ||
3197 | &uart->capabilities); | ||
3179 | 3198 | ||
3180 | ret = uart_add_one_port(&serial8250_reg, &uart->port); | 3199 | ret = uart_add_one_port(&serial8250_reg, &uart->port); |
3181 | if (ret == 0) | 3200 | if (ret == 0) |