Lines Matching +full:auto +full:- +full:baud
1 // SPDX-License-Identifier: GPL-2.0+
3 * Base port operations for 8250/16550-type serial ports
255 * tx_loadsz is set to 63-bytes instead of 64-bytes to implement
256 * workaround of errata A-008006 which states that tx_loadsz should
268 .name = "Palmchip BK-3103",
335 -1, /* UART_SCR (unmapped) */
344 -1, /* UART_LSR (unmapped) */
345 -1, /* UART_MSR (unmapped) */
346 -1, /* UART_SCR (unmapped) */
356 return __raw_readl(p->membase + (offset << p->regshift)); in au_serial_in()
366 __raw_writel(value, p->membase + (offset << p->regshift)); in au_serial_out()
372 return __raw_readl(up->port.membase + 0x28); in au_serial_dl_read()
377 __raw_writel(value, up->port.membase + 0x28); in au_serial_dl_write()
384 offset = offset << p->regshift; in hub6_serial_in()
385 outb(p->hub6 - 1 + offset, p->iobase); in hub6_serial_in()
386 return inb(p->iobase + 1); in hub6_serial_in()
391 offset = offset << p->regshift; in hub6_serial_out()
392 outb(p->hub6 - 1 + offset, p->iobase); in hub6_serial_out()
393 outb(value, p->iobase + 1); in hub6_serial_out()
398 offset = offset << p->regshift; in mem_serial_in()
399 return readb(p->membase + offset); in mem_serial_in()
404 offset = offset << p->regshift; in mem_serial_out()
405 writeb(value, p->membase + offset); in mem_serial_out()
410 offset = offset << p->regshift; in mem16_serial_out()
411 writew(value, p->membase + offset); in mem16_serial_out()
416 offset = offset << p->regshift; in mem16_serial_in()
417 return readw(p->membase + offset); in mem16_serial_in()
422 offset = offset << p->regshift; in mem32_serial_out()
423 writel(value, p->membase + offset); in mem32_serial_out()
428 offset = offset << p->regshift; in mem32_serial_in()
429 return readl(p->membase + offset); in mem32_serial_in()
434 offset = offset << p->regshift; in mem32be_serial_out()
435 iowrite32be(value, p->membase + offset); in mem32be_serial_out()
440 offset = offset << p->regshift; in mem32be_serial_in()
441 return ioread32be(p->membase + offset); in mem32be_serial_in()
446 offset = offset << p->regshift; in io_serial_in()
447 return inb(p->iobase + offset); in io_serial_in()
452 offset = offset << p->regshift; in io_serial_out()
453 outb(value, p->iobase + offset); in io_serial_out()
462 up->dl_read = default_serial_dl_read; in set_io_from_upio()
463 up->dl_write = default_serial_dl_write; in set_io_from_upio()
465 switch (p->iotype) { in set_io_from_upio()
467 p->serial_in = hub6_serial_in; in set_io_from_upio()
468 p->serial_out = hub6_serial_out; in set_io_from_upio()
472 p->serial_in = mem_serial_in; in set_io_from_upio()
473 p->serial_out = mem_serial_out; in set_io_from_upio()
477 p->serial_in = mem16_serial_in; in set_io_from_upio()
478 p->serial_out = mem16_serial_out; in set_io_from_upio()
482 p->serial_in = mem32_serial_in; in set_io_from_upio()
483 p->serial_out = mem32_serial_out; in set_io_from_upio()
487 p->serial_in = mem32be_serial_in; in set_io_from_upio()
488 p->serial_out = mem32be_serial_out; in set_io_from_upio()
493 p->serial_in = au_serial_in; in set_io_from_upio()
494 p->serial_out = au_serial_out; in set_io_from_upio()
495 up->dl_read = au_serial_dl_read; in set_io_from_upio()
496 up->dl_write = au_serial_dl_write; in set_io_from_upio()
501 p->serial_in = io_serial_in; in set_io_from_upio()
502 p->serial_out = io_serial_out; in set_io_from_upio()
506 up->cur_iotype = p->iotype; in set_io_from_upio()
507 p->handle_irq = serial8250_default_handle_irq; in set_io_from_upio()
513 switch (p->iotype) { in serial_port_out_sync()
519 p->serial_out(p, offset, value); in serial_port_out_sync()
520 p->serial_in(p, UART_LCR); /* safe, no side-effects */ in serial_port_out_sync()
523 p->serial_out(p, offset, value); in serial_port_out_sync()
540 serial_icr_write(up, UART_ACR, up->acr | UART_ACR_ICRRD); in serial_icr_read()
543 serial_icr_write(up, UART_ACR, up->acr); in serial_icr_read()
553 if (p->capabilities & UART_CAP_FIFO) { in serial8250_clear_fifos()
567 serial_out(p, UART_FCR, p->fcr); in serial8250_clear_and_reinit_fifos()
573 if (!(p->capabilities & UART_CAP_RPM)) in serial8250_rpm_get()
575 pm_runtime_get_sync(p->port.dev); in serial8250_rpm_get()
581 if (!(p->capabilities & UART_CAP_RPM)) in serial8250_rpm_put()
583 pm_runtime_mark_last_busy(p->port.dev); in serial8250_rpm_put()
584 pm_runtime_put_autosuspend(p->port.dev); in serial8250_rpm_put()
589 * serial8250_em485_init() - put uart_8250_port into rs485 emulating
602 * or from any other callback protected with p->port.lock spinlock.
606 * Return 0 - success, -errno - otherwise
610 if (p->em485) in serial8250_em485_init()
613 p->em485 = kmalloc(sizeof(struct uart_8250_em485), GFP_ATOMIC); in serial8250_em485_init()
614 if (!p->em485) in serial8250_em485_init()
615 return -ENOMEM; in serial8250_em485_init()
617 hrtimer_init(&p->em485->stop_tx_timer, CLOCK_MONOTONIC, in serial8250_em485_init()
619 hrtimer_init(&p->em485->start_tx_timer, CLOCK_MONOTONIC, in serial8250_em485_init()
621 p->em485->stop_tx_timer.function = &serial8250_em485_handle_stop_tx; in serial8250_em485_init()
622 p->em485->start_tx_timer.function = &serial8250_em485_handle_start_tx; in serial8250_em485_init()
623 p->em485->port = p; in serial8250_em485_init()
624 p->em485->active_timer = NULL; in serial8250_em485_init()
625 p->em485->tx_stopped = true; in serial8250_em485_init()
627 p->rs485_stop_tx(p); in serial8250_em485_init()
633 * serial8250_em485_destroy() - put uart_8250_port into normal state
641 * or from any other callback protected with p->port.lock spinlock.
647 if (!p->em485) in serial8250_em485_destroy()
650 hrtimer_cancel(&p->em485->start_tx_timer); in serial8250_em485_destroy()
651 hrtimer_cancel(&p->em485->stop_tx_timer); in serial8250_em485_destroy()
653 kfree(p->em485); in serial8250_em485_destroy()
654 p->em485 = NULL; in serial8250_em485_destroy()
659 * serial8250_em485_config() - generic ->rs485_config() callback
672 if (!!(rs485->flags & SER_RS485_RTS_ON_SEND) == in serial8250_em485_config()
673 !!(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { in serial8250_em485_config()
674 rs485->flags |= SER_RS485_RTS_ON_SEND; in serial8250_em485_config()
675 rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; in serial8250_em485_config()
679 rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U); in serial8250_em485_config()
680 rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U); in serial8250_em485_config()
682 memset(rs485->padding, 0, sizeof(rs485->padding)); in serial8250_em485_config()
683 port->rs485 = *rs485; in serial8250_em485_config()
685 gpiod_set_value(port->rs485_term_gpio, in serial8250_em485_config()
686 rs485->flags & SER_RS485_TERMINATE_BUS); in serial8250_em485_config()
692 if (rs485->flags & SER_RS485_ENABLED) { in serial8250_em485_config()
696 rs485->flags &= ~SER_RS485_ENABLED; in serial8250_em485_config()
697 port->rs485.flags &= ~SER_RS485_ENABLED; in serial8250_em485_config()
716 if (!(p->capabilities & UART_CAP_RPM)) in serial8250_rpm_get_tx()
719 rpm_active = xchg(&p->rpm_tx_active, 1); in serial8250_rpm_get_tx()
722 pm_runtime_get_sync(p->port.dev); in serial8250_rpm_get_tx()
730 if (!(p->capabilities & UART_CAP_RPM)) in serial8250_rpm_put_tx()
733 rpm_active = xchg(&p->rpm_tx_active, 0); in serial8250_rpm_put_tx()
736 pm_runtime_mark_last_busy(p->port.dev); in serial8250_rpm_put_tx()
737 pm_runtime_put_autosuspend(p->port.dev); in serial8250_rpm_put_tx()
752 if (p->capabilities & UART_CAP_SLEEP) { in serial8250_set_sleep()
753 if (p->capabilities & UART_CAP_EFR) { in serial8250_set_sleep()
761 if (p->capabilities & UART_CAP_EFR) { in serial8250_set_sleep()
791 up->port.uartclk = SERIAL_RSA_BAUD_BASE * 16; in __enable_rsa()
798 if (up->port.type == PORT_RSA) { in enable_rsa()
799 if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) { in enable_rsa()
800 spin_lock_irq(&up->port.lock); in enable_rsa()
802 spin_unlock_irq(&up->port.lock); in enable_rsa()
804 if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) in enable_rsa()
820 if (up->port.type == PORT_RSA && in disable_rsa()
821 up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) { in disable_rsa()
822 spin_lock_irq(&up->port.lock); in disable_rsa()
834 up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16; in disable_rsa()
835 spin_unlock_irq(&up->port.lock); in disable_rsa()
863 mdelay(20);/* FIXME - schedule_timeout */ in size_fifo()
877 * Read UART ID using the divisor method - set DLL and DLM to zero
915 up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP; in autoconfig_has_efr()
920 * If we have to do this here because some non-National in autoconfig_has_efr()
934 up->acr = 0; in autoconfig_has_efr()
947 up->port.type = PORT_16C950; in autoconfig_has_efr()
951 * chip which causes it to seriously miscalculate baud rates in autoconfig_has_efr()
955 up->bugs |= UART_BUG_QUOT; in autoconfig_has_efr()
963 * 0x10 - XR16C850 and the DLL contains the chip revision. in autoconfig_has_efr()
964 * 0x12 - XR16C2850. in autoconfig_has_efr()
965 * 0x14 - XR16C854. in autoconfig_has_efr()
972 up->port.type = PORT_16850; in autoconfig_has_efr()
983 * I've had problems doing this in the past. -TYT in autoconfig_has_efr()
986 up->port.type = PORT_16654; in autoconfig_has_efr()
988 up->port.type = PORT_16650V2; in autoconfig_has_efr()
993 * this category - the original 8250 and the 16450. The
1000 up->port.type = PORT_8250; in autoconfig_8250()
1010 up->port.type = PORT_16450; in autoconfig_8250()
1018 * http://linux.derkeiler.com/Mailing-Lists/Kernel/2004-11/4812.html in broken_efr()
1037 up->port.type = PORT_16550A; in autoconfig_16550a()
1038 up->capabilities |= UART_CAP_FIFO; in autoconfig_16550a()
1052 up->port.type = PORT_16650; in autoconfig_16550a()
1053 up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP; in autoconfig_16550a()
1063 up->port.type = PORT_16550A_FSL64; in autoconfig_16550a()
1087 * it's changed. If so, set baud_base in EXCR2 to 921600. -- dwmw2 in autoconfig_16550a()
1115 up->port.uartclk = 921600*16; in autoconfig_16550a()
1116 up->port.type = PORT_NS16550A; in autoconfig_16550a()
1117 up->capabilities |= UART_NATSEMI; in autoconfig_16550a()
1141 up->port.type = PORT_16750; in autoconfig_16550a()
1142 up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP; in autoconfig_16550a()
1168 up->port.type = PORT_XSCALE; in autoconfig_16550a()
1169 up->capabilities |= UART_CAP_UUE | UART_CAP_RTOIE; in autoconfig_16550a()
1185 if (up->port.type == PORT_16550A && size_fifo(up) == 64) { in autoconfig_16550a()
1186 up->port.type = PORT_U6_16550A; in autoconfig_16550a()
1187 up->capabilities |= UART_CAP_AFE; in autoconfig_16550a()
1202 struct uart_port *port = &up->port; in autoconfig()
1206 if (!port->iobase && !port->mapbase && !port->membase) in autoconfig()
1210 port->name, port->iobase, port->membase); in autoconfig()
1213 * We really do need global IRQs disabled here - we're going to in autoconfig()
1216 spin_lock_irqsave(&port->lock, flags); in autoconfig()
1218 up->capabilities = 0; in autoconfig()
1219 up->bugs = 0; in autoconfig()
1221 if (!(port->flags & UPF_BUGGY_UART)) { in autoconfig()
1228 * assumption is that 0x80 is a non-existent port; in autoconfig()
1255 spin_unlock_irqrestore(&port->lock, flags); in autoconfig()
1272 * that conflicts with COM 1-4 --- we hope! in autoconfig()
1274 if (!(port->flags & UPF_SKIP_TEST)) { in autoconfig()
1279 spin_unlock_irqrestore(&port->lock, flags); in autoconfig()
1307 port->type = PORT_UNKNOWN; in autoconfig()
1310 port->type = PORT_16550; in autoconfig()
1321 if (port->type == PORT_16550A && up->probe & UART_PROBE_RSA && in autoconfig()
1323 port->type = PORT_RSA; in autoconfig()
1328 port->fifosize = uart_config[up->port.type].fifo_size; in autoconfig()
1329 old_capabilities = up->capabilities; in autoconfig()
1330 up->capabilities = uart_config[port->type].flags; in autoconfig()
1331 up->tx_loadsz = uart_config[port->type].tx_loadsz; in autoconfig()
1333 if (port->type == PORT_UNKNOWN) in autoconfig()
1340 if (port->type == PORT_RSA) in autoconfig()
1346 if (up->capabilities & UART_CAP_UUE) in autoconfig()
1352 spin_unlock_irqrestore(&port->lock, flags); in autoconfig()
1357 if (port->type == PORT_16550A && port->iotype == UPIO_PORT) in autoconfig()
1360 if (up->capabilities != old_capabilities) { in autoconfig()
1361 dev_warn(port->dev, "detected caps %08x should be %08x\n", in autoconfig()
1362 old_capabilities, up->capabilities); in autoconfig()
1366 DEBUG_AUTOCONF("type=%s\n", uart_config[port->type].name); in autoconfig()
1371 struct uart_port *port = &up->port; in autoconfig_irq()
1378 if (port->flags & UPF_FOURPORT) { in autoconfig_irq()
1379 ICP = (port->iobase & 0xfe0) | 0x1f; in autoconfig_irq()
1397 if (port->flags & UPF_FOURPORT) { in autoconfig_irq()
1415 if (port->flags & UPF_FOURPORT) in autoconfig_irq()
1421 port->irq = (irq > 0) ? irq : 0; in autoconfig_irq()
1430 up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); in serial8250_stop_rx()
1431 up->port.read_status_mask &= ~UART_LSR_DR; in serial8250_stop_rx()
1432 serial_port_out(port, UART_IER, up->ier); in serial8250_stop_rx()
1438 * serial8250_em485_stop_tx() - generic ->rs485_stop_tx() callback
1447 if (p->port.rs485.flags & SER_RS485_RTS_AFTER_SEND) in serial8250_em485_stop_tx()
1455 * received during the half-duplex transmission. in serial8250_em485_stop_tx()
1458 if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) { in serial8250_em485_stop_tx()
1461 p->ier |= UART_IER_RLSI | UART_IER_RDI; in serial8250_em485_stop_tx()
1462 serial_port_out(&p->port, UART_IER, p->ier); in serial8250_em485_stop_tx()
1474 p = em485->port; in serial8250_em485_handle_stop_tx()
1477 spin_lock_irqsave(&p->port.lock, flags); in serial8250_em485_handle_stop_tx()
1478 if (em485->active_timer == &em485->stop_tx_timer) { in serial8250_em485_handle_stop_tx()
1479 p->rs485_stop_tx(p); in serial8250_em485_handle_stop_tx()
1480 em485->active_timer = NULL; in serial8250_em485_handle_stop_tx()
1481 em485->tx_stopped = true; in serial8250_em485_handle_stop_tx()
1483 spin_unlock_irqrestore(&p->port.lock, flags); in serial8250_em485_handle_stop_tx()
1499 struct uart_8250_em485 *em485 = p->em485; in __stop_tx_rs485()
1505 if (p->port.rs485.delay_rts_after_send > 0) { in __stop_tx_rs485()
1506 em485->active_timer = &em485->stop_tx_timer; in __stop_tx_rs485()
1507 start_hrtimer_ms(&em485->stop_tx_timer, in __stop_tx_rs485()
1508 p->port.rs485.delay_rts_after_send); in __stop_tx_rs485()
1510 p->rs485_stop_tx(p); in __stop_tx_rs485()
1511 em485->active_timer = NULL; in __stop_tx_rs485()
1512 em485->tx_stopped = true; in __stop_tx_rs485()
1524 struct uart_8250_em485 *em485 = p->em485; in __stop_tx()
1552 if (port->type == PORT_16C950) { in serial8250_stop_tx()
1553 up->acr |= UART_ACR_TXDIS; in serial8250_stop_tx()
1554 serial_icr_write(up, UART_ACR, up->acr); in serial8250_stop_tx()
1563 if (up->dma && !up->dma->tx_dma(up)) in __start_tx()
1567 if (up->bugs & UART_BUG_TXEN) { in __start_tx()
1571 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; in __start_tx()
1578 * Re-enable the transmitter if we disabled it. in __start_tx()
1580 if (port->type == PORT_16C950 && up->acr & UART_ACR_TXDIS) { in __start_tx()
1581 up->acr &= ~UART_ACR_TXDIS; in __start_tx()
1582 serial_icr_write(up, UART_ACR, up->acr); in __start_tx()
1587 * serial8250_em485_start_tx() - generic ->rs485_start_tx() callback
1600 if (!(up->port.rs485.flags & SER_RS485_RX_DURING_TX)) in serial8250_em485_start_tx()
1601 serial8250_stop_rx(&up->port); in serial8250_em485_start_tx()
1603 if (up->port.rs485.flags & SER_RS485_RTS_ON_SEND) in serial8250_em485_start_tx()
1614 struct uart_8250_em485 *em485 = up->em485; in start_tx_rs485()
1616 em485->active_timer = NULL; in start_tx_rs485()
1618 if (em485->tx_stopped) { in start_tx_rs485()
1619 em485->tx_stopped = false; in start_tx_rs485()
1621 up->rs485_start_tx(up); in start_tx_rs485()
1623 if (up->port.rs485.delay_rts_before_send > 0) { in start_tx_rs485()
1624 em485->active_timer = &em485->start_tx_timer; in start_tx_rs485()
1625 start_hrtimer_ms(&em485->start_tx_timer, in start_tx_rs485()
1626 up->port.rs485.delay_rts_before_send); in start_tx_rs485()
1641 p = em485->port; in serial8250_em485_handle_start_tx()
1643 spin_lock_irqsave(&p->port.lock, flags); in serial8250_em485_handle_start_tx()
1644 if (em485->active_timer == &em485->start_tx_timer) { in serial8250_em485_handle_start_tx()
1645 __start_tx(&p->port); in serial8250_em485_handle_start_tx()
1646 em485->active_timer = NULL; in serial8250_em485_handle_start_tx()
1648 spin_unlock_irqrestore(&p->port.lock, flags); in serial8250_em485_handle_start_tx()
1655 struct uart_8250_em485 *em485 = up->em485; in serial8250_start_tx()
1660 em485->active_timer == &em485->start_tx_timer) in serial8250_start_tx()
1671 port->throttle(port); in serial8250_throttle()
1676 port->unthrottle(port); in serial8250_unthrottle()
1684 if (up->bugs & UART_BUG_NOMSR) in serial8250_disable_ms()
1687 mctrl_gpio_disable_ms(up->gpios); in serial8250_disable_ms()
1689 up->ier &= ~UART_IER_MSI; in serial8250_disable_ms()
1690 serial_port_out(port, UART_IER, up->ier); in serial8250_disable_ms()
1698 if (up->bugs & UART_BUG_NOMSR) in serial8250_enable_ms()
1701 mctrl_gpio_enable_ms(up->gpios); in serial8250_enable_ms()
1703 up->ier |= UART_IER_MSI; in serial8250_enable_ms()
1706 serial_port_out(port, UART_IER, up->ier); in serial8250_enable_ms()
1712 struct uart_port *port = &up->port; in serial8250_read_char()
1728 port->icount.rx++; in serial8250_read_char()
1730 lsr |= up->lsr_saved_flags; in serial8250_read_char()
1731 up->lsr_saved_flags = 0; in serial8250_read_char()
1736 port->icount.brk++; in serial8250_read_char()
1746 port->icount.parity++; in serial8250_read_char()
1748 port->icount.frame++; in serial8250_read_char()
1750 port->icount.overrun++; in serial8250_read_char()
1755 lsr &= port->read_status_mask; in serial8250_read_char()
1758 dev_dbg(port->dev, "handling break\n"); in serial8250_read_char()
1779 struct uart_port *port = &up->port; in serial8250_rx_chars()
1784 if (--max_count == 0) in serial8250_rx_chars()
1789 tty_flip_buffer_push(&port->state->port); in serial8250_rx_chars()
1796 struct uart_port *port = &up->port; in serial8250_tx_chars()
1797 struct circ_buf *xmit = &port->state->xmit; in serial8250_tx_chars()
1800 if (port->x_char) { in serial8250_tx_chars()
1801 serial_out(up, UART_TX, port->x_char); in serial8250_tx_chars()
1802 port->icount.tx++; in serial8250_tx_chars()
1803 port->x_char = 0; in serial8250_tx_chars()
1815 count = up->tx_loadsz; in serial8250_tx_chars()
1817 serial_out(up, UART_TX, xmit->buf[xmit->tail]); in serial8250_tx_chars()
1818 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); in serial8250_tx_chars()
1819 port->icount.tx++; in serial8250_tx_chars()
1822 if ((up->capabilities & UART_CAP_HFIFO) && in serial8250_tx_chars()
1825 /* The BCM2835 MINI UART THRE bit is really a not-full bit. */ in serial8250_tx_chars()
1826 if ((up->capabilities & UART_CAP_MINI) && in serial8250_tx_chars()
1829 } while (--count > 0); in serial8250_tx_chars()
1839 if (uart_circ_empty(xmit) && !(up->capabilities & UART_CAP_RPM)) in serial8250_tx_chars()
1847 struct uart_port *port = &up->port; in serial8250_modem_status()
1850 status |= up->msr_saved_flags; in serial8250_modem_status()
1851 up->msr_saved_flags = 0; in serial8250_modem_status()
1852 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI && in serial8250_modem_status()
1853 port->state != NULL) { in serial8250_modem_status()
1855 port->icount.rng++; in serial8250_modem_status()
1857 port->icount.dsr++; in serial8250_modem_status()
1863 wake_up_interruptible(&port->state->port.delta_msr_wait); in serial8250_modem_status()
1879 return up->dma->rx_dma(up); in handle_rx_dma()
1895 spin_lock_irqsave(&port->lock, flags); in serial8250_handle_irq()
1902 * overflow. Not servicing, RX FIFO would trigger auto HW flow in serial8250_handle_irq()
1904 * halting RX. This only works when auto HW flow control is in serial8250_handle_irq()
1908 (port->status & (UPSTAT_AUTOCTS | UPSTAT_AUTORTS)) && in serial8250_handle_irq()
1909 !(port->read_status_mask & UART_LSR_DR)) in serial8250_handle_irq()
1913 if (!up->dma || handle_rx_dma(up, iir)) in serial8250_handle_irq()
1917 if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE) && in serial8250_handle_irq()
1918 (up->ier & UART_IER_THRI)) in serial8250_handle_irq()
1956 spin_lock_irqsave(&port->lock, flags); in serial8250_tx_threshold_handle_irq()
1958 spin_unlock_irqrestore(&port->lock, flags); in serial8250_tx_threshold_handle_irq()
1973 spin_lock_irqsave(&port->lock, flags); in serial8250_tx_empty()
1975 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; in serial8250_tx_empty()
1976 spin_unlock_irqrestore(&port->lock, flags); in serial8250_tx_empty()
1994 if (up->gpios) in serial8250_do_get_mctrl()
1995 return mctrl_gpio_get(up->gpios, &val); in serial8250_do_get_mctrl()
2003 if (port->get_mctrl) in serial8250_get_mctrl()
2004 return port->get_mctrl(port); in serial8250_get_mctrl()
2013 if (port->rs485.flags & SER_RS485_ENABLED) { in serial8250_do_set_mctrl()
2022 mcr = (mcr & up->mcr_mask) | up->mcr_force | up->mcr; in serial8250_do_set_mctrl()
2030 if (port->set_mctrl) in serial8250_set_mctrl()
2031 port->set_mctrl(port, mctrl); in serial8250_set_mctrl()
2042 spin_lock_irqsave(&port->lock, flags); in serial8250_break_ctl()
2043 if (break_state == -1) in serial8250_break_ctl()
2044 up->lcr |= UART_LCR_SBC; in serial8250_break_ctl()
2046 up->lcr &= ~UART_LCR_SBC; in serial8250_break_ctl()
2047 serial_port_out(port, UART_LCR, up->lcr); in serial8250_break_ctl()
2048 spin_unlock_irqrestore(&port->lock, flags); in serial8250_break_ctl()
2063 up->lsr_saved_flags |= status & LSR_SAVE_FLAGS; in wait_for_xmitr()
2067 if (--tmout == 0) in wait_for_xmitr()
2074 if (up->port.flags & UPF_CONS_FLOW) { in wait_for_xmitr()
2075 for (tmout = 1000000; tmout; tmout--) { in wait_for_xmitr()
2077 up->msr_saved_flags |= msr & MSR_SAVE_FLAGS; in wait_for_xmitr()
2125 if (up->capabilities & UART_CAP_UUE) in serial8250_put_poll_char()
2154 if (!port->fifosize) in serial8250_do_startup()
2155 port->fifosize = uart_config[port->type].fifo_size; in serial8250_do_startup()
2156 if (!up->tx_loadsz) in serial8250_do_startup()
2157 up->tx_loadsz = uart_config[port->type].tx_loadsz; in serial8250_do_startup()
2158 if (!up->capabilities) in serial8250_do_startup()
2159 up->capabilities = uart_config[port->type].flags; in serial8250_do_startup()
2160 up->mcr = 0; in serial8250_do_startup()
2162 if (port->iotype != up->cur_iotype) in serial8250_do_startup()
2166 if (port->type == PORT_16C950) { in serial8250_do_startup()
2168 up->acr = 0; in serial8250_do_startup()
2179 if (port->type == PORT_DA830) { in serial8250_do_startup()
2192 if (port->type == PORT_NPCM) { in serial8250_do_startup()
2228 if (!(port->flags & UPF_BUGGY_UART) && in serial8250_do_startup()
2230 dev_info_ratelimited(port->dev, "LSR safety check engaged!\n"); in serial8250_do_startup()
2231 retval = -ENODEV; in serial8250_do_startup()
2238 if (port->type == PORT_16850) { in serial8250_do_startup()
2257 if (((port->type == PORT_ALTR_16550_F32) || in serial8250_do_startup()
2258 (port->type == PORT_ALTR_16550_F64) || in serial8250_do_startup()
2259 (port->type == PORT_ALTR_16550_F128)) && (port->fifosize > 1)) { in serial8250_do_startup()
2260 /* Bounds checking of TX threshold (valid 0 to fifosize-2) */ in serial8250_do_startup()
2261 if ((up->tx_loadsz < 2) || (up->tx_loadsz > port->fifosize)) { in serial8250_do_startup()
2262 dev_err(port->dev, "TX FIFO Threshold errors, skipping\n"); in serial8250_do_startup()
2267 port->fifosize - up->tx_loadsz); in serial8250_do_startup()
2268 port->handle_irq = serial8250_tx_threshold_handle_irq; in serial8250_do_startup()
2273 if (port->irq && (up->port.flags & UPF_SHARE_IRQ)) in serial8250_do_startup()
2274 up->port.irqflags |= IRQF_SHARED; in serial8250_do_startup()
2276 if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) { in serial8250_do_startup()
2279 if (port->irqflags & IRQF_SHARED) in serial8250_do_startup()
2280 disable_irq_nosync(port->irq); in serial8250_do_startup()
2290 spin_lock_irqsave(&port->lock, flags); in serial8250_do_startup()
2298 udelay(1); /* allow a working UART time to re-assert THRE */ in serial8250_do_startup()
2302 spin_unlock_irqrestore(&port->lock, flags); in serial8250_do_startup()
2304 if (port->irqflags & IRQF_SHARED) in serial8250_do_startup()
2305 enable_irq(port->irq); in serial8250_do_startup()
2313 up->port.flags & UPF_BUG_THRE) { in serial8250_do_startup()
2314 up->bugs |= UART_BUG_THRE; in serial8250_do_startup()
2318 retval = up->ops->setup_irq(up); in serial8250_do_startup()
2327 spin_lock_irqsave(&port->lock, flags); in serial8250_do_startup()
2328 if (up->port.flags & UPF_FOURPORT) { in serial8250_do_startup()
2329 if (!up->port.irq) in serial8250_do_startup()
2330 up->port.mctrl |= TIOCM_OUT1; in serial8250_do_startup()
2335 if (port->irq) in serial8250_do_startup()
2336 up->port.mctrl |= TIOCM_OUT2; in serial8250_do_startup()
2338 serial8250_set_mctrl(port, port->mctrl); in serial8250_do_startup()
2351 if (up->port.quirks & UPQ_NO_TXEN_TEST) in serial8250_do_startup()
2364 if (!(up->bugs & UART_BUG_TXEN)) { in serial8250_do_startup()
2365 up->bugs |= UART_BUG_TXEN; in serial8250_do_startup()
2366 dev_dbg(port->dev, "enabling bad tx status workarounds\n"); in serial8250_do_startup()
2369 up->bugs &= ~UART_BUG_TXEN; in serial8250_do_startup()
2373 spin_unlock_irqrestore(&port->lock, flags); in serial8250_do_startup()
2384 up->lsr_saved_flags = 0; in serial8250_do_startup()
2385 up->msr_saved_flags = 0; in serial8250_do_startup()
2390 if (up->dma) { in serial8250_do_startup()
2398 dev_warn_ratelimited(port->dev, "%s\n", msg); in serial8250_do_startup()
2399 up->dma = NULL; in serial8250_do_startup()
2405 * enable until after the FIFOs are enabled; otherwise, an already- in serial8250_do_startup()
2408 up->ier = UART_IER_RLSI | UART_IER_RDI; in serial8250_do_startup()
2410 if (port->flags & UPF_FOURPORT) { in serial8250_do_startup()
2415 icp = (port->iobase & 0xfe0) | 0x01f; in serial8250_do_startup()
2428 if (port->startup) in serial8250_startup()
2429 return port->startup(port); in serial8250_startup()
2442 spin_lock_irqsave(&port->lock, flags); in serial8250_do_shutdown()
2443 up->ier = 0; in serial8250_do_shutdown()
2445 spin_unlock_irqrestore(&port->lock, flags); in serial8250_do_shutdown()
2447 synchronize_irq(port->irq); in serial8250_do_shutdown()
2449 if (up->dma) in serial8250_do_shutdown()
2452 spin_lock_irqsave(&port->lock, flags); in serial8250_do_shutdown()
2453 if (port->flags & UPF_FOURPORT) { in serial8250_do_shutdown()
2455 inb((port->iobase & 0xfe0) | 0x1f); in serial8250_do_shutdown()
2456 port->mctrl |= TIOCM_OUT1; in serial8250_do_shutdown()
2458 port->mctrl &= ~TIOCM_OUT2; in serial8250_do_shutdown()
2460 serial8250_set_mctrl(port, port->mctrl); in serial8250_do_shutdown()
2461 spin_unlock_irqrestore(&port->lock, flags); in serial8250_do_shutdown()
2484 up->ops->release_irq(up); in serial8250_do_shutdown()
2490 if (port->shutdown) in serial8250_shutdown()
2491 port->shutdown(port); in serial8250_shutdown()
2498 unsigned int baud) in npcm_get_divisor() argument
2500 struct uart_port *port = &up->port; in npcm_get_divisor()
2502 return DIV_ROUND_CLOSEST(port->uartclk, 16 * baud + 2) - 2; in npcm_get_divisor()
2506 unsigned int baud, in serial8250_do_get_divisor() argument
2513 * Handle magic divisors for baud rates above baud_base on in serial8250_do_get_divisor()
2517 if ((port->flags & UPF_MAGIC_MULTIPLIER) && in serial8250_do_get_divisor()
2518 baud == (port->uartclk/4)) in serial8250_do_get_divisor()
2520 else if ((port->flags & UPF_MAGIC_MULTIPLIER) && in serial8250_do_get_divisor()
2521 baud == (port->uartclk/8)) in serial8250_do_get_divisor()
2523 else if (up->port.type == PORT_NPCM) in serial8250_do_get_divisor()
2524 quot = npcm_get_divisor(up, baud); in serial8250_do_get_divisor()
2526 quot = uart_get_divisor(port, baud); in serial8250_do_get_divisor()
2531 if (up->bugs & UART_BUG_QUOT && (quot & 0xff) == 0) in serial8250_do_get_divisor()
2538 unsigned int baud, in serial8250_get_divisor() argument
2541 if (port->get_divisor) in serial8250_get_divisor()
2542 return port->get_divisor(port, baud, frac); in serial8250_get_divisor()
2544 return serial8250_do_get_divisor(port, baud, frac); in serial8250_get_divisor()
2572 if (up->bugs & UART_BUG_PARITY) in serial8250_compute_lcr()
2573 up->fifo_bug = true; in serial8250_compute_lcr()
2585 void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud, in serial8250_do_set_divisor() argument
2590 /* Workaround to enable 115200 baud on OMAP1510 internal ports */ in serial8250_do_set_divisor()
2592 if (baud == 115200) { in serial8250_do_set_divisor()
2603 if (up->capabilities & UART_NATSEMI) in serial8250_do_set_divisor()
2606 serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB); in serial8250_do_set_divisor()
2612 static void serial8250_set_divisor(struct uart_port *port, unsigned int baud, in serial8250_set_divisor() argument
2615 if (port->set_divisor) in serial8250_set_divisor()
2616 port->set_divisor(port, baud, quot, quot_frac); in serial8250_set_divisor()
2618 serial8250_do_set_divisor(port, baud, quot, quot_frac); in serial8250_set_divisor()
2625 unsigned int tolerance = port->uartclk / 100; in serial8250_get_baud_rate()
2630 * slower than nominal still match standard baud rates without in serial8250_get_baud_rate()
2634 port->uartclk / 16 / UART_DIV_MAX, in serial8250_get_baud_rate()
2635 (port->uartclk + tolerance) / 16); in serial8250_get_baud_rate()
2646 unsigned int baud, quot, frac = 0; in serial8250_update_uartclk() local
2650 mutex_lock(&port->state->port.mutex); in serial8250_update_uartclk()
2652 if (port->uartclk == uartclk) in serial8250_update_uartclk()
2655 port->uartclk = uartclk; in serial8250_update_uartclk()
2657 if (!tty_port_initialized(&port->state->port)) in serial8250_update_uartclk()
2660 termios = &port->state->port.tty->termios; in serial8250_update_uartclk()
2662 baud = serial8250_get_baud_rate(port, termios, NULL); in serial8250_update_uartclk()
2663 quot = serial8250_get_divisor(port, baud, &frac); in serial8250_update_uartclk()
2666 spin_lock_irqsave(&port->lock, flags); in serial8250_update_uartclk()
2668 uart_update_timeout(port, termios->c_cflag, baud); in serial8250_update_uartclk()
2670 serial8250_set_divisor(port, baud, quot, frac); in serial8250_update_uartclk()
2671 serial_port_out(port, UART_LCR, up->lcr); in serial8250_update_uartclk()
2673 spin_unlock_irqrestore(&port->lock, flags); in serial8250_update_uartclk()
2677 mutex_unlock(&port->state->port.mutex); in serial8250_update_uartclk()
2688 unsigned int baud, quot, frac = 0; in serial8250_do_set_termios() local
2690 if (up->capabilities & UART_CAP_MINI) { in serial8250_do_set_termios()
2691 termios->c_cflag &= ~(CSTOPB | PARENB | PARODD | CMSPAR); in serial8250_do_set_termios()
2692 if ((termios->c_cflag & CSIZE) == CS5 || in serial8250_do_set_termios()
2693 (termios->c_cflag & CSIZE) == CS6) in serial8250_do_set_termios()
2694 termios->c_cflag = (termios->c_cflag & ~CSIZE) | CS7; in serial8250_do_set_termios()
2696 cval = serial8250_compute_lcr(up, termios->c_cflag); in serial8250_do_set_termios()
2698 baud = serial8250_get_baud_rate(port, termios, old); in serial8250_do_set_termios()
2699 quot = serial8250_get_divisor(port, baud, &frac); in serial8250_do_set_termios()
2706 spin_lock_irqsave(&port->lock, flags); in serial8250_do_set_termios()
2708 up->lcr = cval; /* Save computed LCR */ in serial8250_do_set_termios()
2710 if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) { in serial8250_do_set_termios()
2712 if ((baud < 2400 && !up->dma) || up->fifo_bug) { in serial8250_do_set_termios()
2713 up->fcr &= ~UART_FCR_TRIGGER_MASK; in serial8250_do_set_termios()
2714 up->fcr |= UART_FCR_TRIGGER_1; in serial8250_do_set_termios()
2719 * MCR-based auto flow control. When AFE is enabled, RTS will be in serial8250_do_set_termios()
2723 if (up->capabilities & UART_CAP_AFE) { in serial8250_do_set_termios()
2724 up->mcr &= ~UART_MCR_AFE; in serial8250_do_set_termios()
2725 if (termios->c_cflag & CRTSCTS) in serial8250_do_set_termios()
2726 up->mcr |= UART_MCR_AFE; in serial8250_do_set_termios()
2730 * Update the per-port timeout. in serial8250_do_set_termios()
2732 uart_update_timeout(port, termios->c_cflag, baud); in serial8250_do_set_termios()
2734 port->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; in serial8250_do_set_termios()
2735 if (termios->c_iflag & INPCK) in serial8250_do_set_termios()
2736 port->read_status_mask |= UART_LSR_FE | UART_LSR_PE; in serial8250_do_set_termios()
2737 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) in serial8250_do_set_termios()
2738 port->read_status_mask |= UART_LSR_BI; in serial8250_do_set_termios()
2743 port->ignore_status_mask = 0; in serial8250_do_set_termios()
2744 if (termios->c_iflag & IGNPAR) in serial8250_do_set_termios()
2745 port->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE; in serial8250_do_set_termios()
2746 if (termios->c_iflag & IGNBRK) { in serial8250_do_set_termios()
2747 port->ignore_status_mask |= UART_LSR_BI; in serial8250_do_set_termios()
2752 if (termios->c_iflag & IGNPAR) in serial8250_do_set_termios()
2753 port->ignore_status_mask |= UART_LSR_OE; in serial8250_do_set_termios()
2759 if ((termios->c_cflag & CREAD) == 0) in serial8250_do_set_termios()
2760 port->ignore_status_mask |= UART_LSR_DR; in serial8250_do_set_termios()
2765 up->ier &= ~UART_IER_MSI; in serial8250_do_set_termios()
2766 if (!(up->bugs & UART_BUG_NOMSR) && in serial8250_do_set_termios()
2767 UART_ENABLE_MS(&up->port, termios->c_cflag)) in serial8250_do_set_termios()
2768 up->ier |= UART_IER_MSI; in serial8250_do_set_termios()
2769 if (up->capabilities & UART_CAP_UUE) in serial8250_do_set_termios()
2770 up->ier |= UART_IER_UUE; in serial8250_do_set_termios()
2771 if (up->capabilities & UART_CAP_RTOIE) in serial8250_do_set_termios()
2772 up->ier |= UART_IER_RTOIE; in serial8250_do_set_termios()
2774 serial_port_out(port, UART_IER, up->ier); in serial8250_do_set_termios()
2776 if (up->capabilities & UART_CAP_EFR) { in serial8250_do_set_termios()
2780 * - TI16C752 requires control thresholds to be set. in serial8250_do_set_termios()
2781 * - UART_MCR_RTS is ineffective if auto-RTS mode is enabled. in serial8250_do_set_termios()
2783 if (termios->c_cflag & CRTSCTS) in serial8250_do_set_termios()
2787 if (port->flags & UPF_EXAR_EFR) in serial8250_do_set_termios()
2793 serial8250_set_divisor(port, baud, quot, frac); in serial8250_do_set_termios()
2796 * LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR in serial8250_do_set_termios()
2799 if (port->type == PORT_16750) in serial8250_do_set_termios()
2800 serial_port_out(port, UART_FCR, up->fcr); in serial8250_do_set_termios()
2802 serial_port_out(port, UART_LCR, up->lcr); /* reset DLAB */ in serial8250_do_set_termios()
2803 if (port->type != PORT_16750) { in serial8250_do_set_termios()
2805 if (up->fcr & UART_FCR_ENABLE_FIFO) in serial8250_do_set_termios()
2807 serial_port_out(port, UART_FCR, up->fcr); /* set fcr */ in serial8250_do_set_termios()
2809 serial8250_set_mctrl(port, port->mctrl); in serial8250_do_set_termios()
2810 spin_unlock_irqrestore(&port->lock, flags); in serial8250_do_set_termios()
2815 tty_termios_encode_baud_rate(termios, baud, baud); in serial8250_do_set_termios()
2823 if (port->set_termios) in serial8250_set_termios()
2824 port->set_termios(port, termios, old); in serial8250_set_termios()
2831 if (termios->c_line == N_PPS) { in serial8250_do_set_ldisc()
2832 port->flags |= UPF_HARDPPS_CD; in serial8250_do_set_ldisc()
2833 spin_lock_irq(&port->lock); in serial8250_do_set_ldisc()
2835 spin_unlock_irq(&port->lock); in serial8250_do_set_ldisc()
2837 port->flags &= ~UPF_HARDPPS_CD; in serial8250_do_set_ldisc()
2838 if (!UART_ENABLE_MS(port, termios->c_cflag)) { in serial8250_do_set_ldisc()
2839 spin_lock_irq(&port->lock); in serial8250_do_set_ldisc()
2841 spin_unlock_irq(&port->lock); in serial8250_do_set_ldisc()
2850 if (port->set_ldisc) in serial8250_set_ldisc()
2851 port->set_ldisc(port, termios); in serial8250_set_ldisc()
2869 if (port->pm) in serial8250_pm()
2870 port->pm(port, state, oldstate); in serial8250_pm()
2877 if (pt->port.mapsize) in serial8250_port_size()
2878 return pt->port.mapsize; in serial8250_port_size()
2879 if (pt->port.iotype == UPIO_AU) { in serial8250_port_size()
2880 if (pt->port.type == PORT_RT2880) in serial8250_port_size()
2885 return 0x16 << pt->port.regshift; in serial8250_port_size()
2887 return 8 << pt->port.regshift; in serial8250_port_size()
2896 struct uart_port *port = &up->port; in serial8250_request_std_resource()
2899 switch (port->iotype) { in serial8250_request_std_resource()
2906 if (!port->mapbase) in serial8250_request_std_resource()
2909 if (!request_mem_region(port->mapbase, size, "serial")) { in serial8250_request_std_resource()
2910 ret = -EBUSY; in serial8250_request_std_resource()
2914 if (port->flags & UPF_IOREMAP) { in serial8250_request_std_resource()
2915 port->membase = ioremap(port->mapbase, size); in serial8250_request_std_resource()
2916 if (!port->membase) { in serial8250_request_std_resource()
2917 release_mem_region(port->mapbase, size); in serial8250_request_std_resource()
2918 ret = -ENOMEM; in serial8250_request_std_resource()
2925 if (!request_region(port->iobase, size, "serial")) in serial8250_request_std_resource()
2926 ret = -EBUSY; in serial8250_request_std_resource()
2935 struct uart_port *port = &up->port; in serial8250_release_std_resource()
2937 switch (port->iotype) { in serial8250_release_std_resource()
2944 if (!port->mapbase) in serial8250_release_std_resource()
2947 if (port->flags & UPF_IOREMAP) { in serial8250_release_std_resource()
2948 iounmap(port->membase); in serial8250_release_std_resource()
2949 port->membase = NULL; in serial8250_release_std_resource()
2952 release_mem_region(port->mapbase, size); in serial8250_release_std_resource()
2957 release_region(port->iobase, size); in serial8250_release_std_resource()
2978 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in fcr_get_rxtrig_bytes()
2981 bytes = conf_type->rxtrig_bytes[UART_FCR_R_TRIG_BITS(up->fcr)]; in fcr_get_rxtrig_bytes()
2983 return bytes ? bytes : -EOPNOTSUPP; in fcr_get_rxtrig_bytes()
2988 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in bytes_to_fcr_rxtrig()
2991 if (!conf_type->rxtrig_bytes[UART_FCR_R_TRIG_BITS(UART_FCR_R_TRIG_00)]) in bytes_to_fcr_rxtrig()
2992 return -EOPNOTSUPP; in bytes_to_fcr_rxtrig()
2995 if (bytes < conf_type->rxtrig_bytes[i]) in bytes_to_fcr_rxtrig()
2997 return (--i) << UART_FCR_R_TRIG_SHIFT; in bytes_to_fcr_rxtrig()
3006 struct uart_port *uport = state->uart_port; in do_get_rxtrig()
3009 if (!(up->capabilities & UART_CAP_FIFO) || uport->fifosize <= 1) in do_get_rxtrig()
3010 return -EINVAL; in do_get_rxtrig()
3019 mutex_lock(&port->mutex); in do_serial8250_get_rxtrig()
3021 mutex_unlock(&port->mutex); in do_serial8250_get_rxtrig()
3042 struct uart_port *uport = state->uart_port; in do_set_rxtrig()
3046 if (!(up->capabilities & UART_CAP_FIFO) || uport->fifosize <= 1 || in do_set_rxtrig()
3047 up->fifo_bug) in do_set_rxtrig()
3048 return -EINVAL; in do_set_rxtrig()
3055 up->fcr &= ~UART_FCR_TRIGGER_MASK; in do_set_rxtrig()
3056 up->fcr |= (unsigned char)rxtrig; in do_set_rxtrig()
3057 serial_out(up, UART_FCR, up->fcr); in do_set_rxtrig()
3065 mutex_lock(&port->mutex); in do_serial8250_set_rxtrig()
3067 mutex_unlock(&port->mutex); in do_serial8250_set_rxtrig()
3080 return -EINVAL; in rx_trig_bytes_store()
3106 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in register_dev_spec_attr_grp()
3108 if (conf_type->rxtrig_bytes[0]) in register_dev_spec_attr_grp()
3109 up->port.attr_group = &serial8250_dev_attr_group; in register_dev_spec_attr_grp()
3125 if (port->iotype != up->cur_iotype) in serial8250_config_port()
3131 if (port->rs485.flags & SER_RS485_ENABLED) in serial8250_config_port()
3132 port->rs485_config(port, &port->rs485); in serial8250_config_port()
3135 if (port->type == PORT_16550A && port->iotype == UPIO_AU) in serial8250_config_port()
3136 up->bugs |= UART_BUG_NOMSR; in serial8250_config_port()
3139 if (port->type == PORT_TEGRA) in serial8250_config_port()
3140 up->bugs |= UART_BUG_NOMSR; in serial8250_config_port()
3142 if (port->type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ) in serial8250_config_port()
3145 if (port->type == PORT_UNKNOWN) in serial8250_config_port()
3149 up->fcr = uart_config[up->port.type].fcr; in serial8250_config_port()
3155 if (ser->irq >= nr_irqs || ser->irq < 0 || in serial8250_verify_port()
3156 ser->baud_base < 9600 || ser->type < PORT_UNKNOWN || in serial8250_verify_port()
3157 ser->type >= ARRAY_SIZE(uart_config) || ser->type == PORT_CIRRUS || in serial8250_verify_port()
3158 ser->type == PORT_STARTECH) in serial8250_verify_port()
3159 return -EINVAL; in serial8250_verify_port()
3165 int type = port->type; in serial8250_type()
3201 struct uart_port *port = &up->port; in serial8250_init_port()
3203 spin_lock_init(&port->lock); in serial8250_init_port()
3204 port->ops = &serial8250_pops; in serial8250_init_port()
3205 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE); in serial8250_init_port()
3207 up->cur_iotype = 0xFF; in serial8250_init_port()
3213 struct uart_port *port = &up->port; in serial8250_set_defaults()
3215 if (up->port.flags & UPF_FIXED_TYPE) { in serial8250_set_defaults()
3216 unsigned int type = up->port.type; in serial8250_set_defaults()
3218 if (!up->port.fifosize) in serial8250_set_defaults()
3219 up->port.fifosize = uart_config[type].fifo_size; in serial8250_set_defaults()
3220 if (!up->tx_loadsz) in serial8250_set_defaults()
3221 up->tx_loadsz = uart_config[type].tx_loadsz; in serial8250_set_defaults()
3222 if (!up->capabilities) in serial8250_set_defaults()
3223 up->capabilities = uart_config[type].flags; in serial8250_set_defaults()
3229 if (up->dma) { in serial8250_set_defaults()
3230 if (!up->dma->tx_dma) in serial8250_set_defaults()
3231 up->dma->tx_dma = serial8250_tx_dma; in serial8250_set_defaults()
3232 if (!up->dma->rx_dma) in serial8250_set_defaults()
3233 up->dma->rx_dma = serial8250_rx_dma; in serial8250_set_defaults()
3249 * Restore serial console when h/w power-off detected
3253 struct uart_port *port = &up->port; in serial8250_console_restore()
3255 unsigned int baud, quot, frac = 0; in serial8250_console_restore() local
3257 termios.c_cflag = port->cons->cflag; in serial8250_console_restore()
3258 if (port->state->port.tty && termios.c_cflag == 0) in serial8250_console_restore()
3259 termios.c_cflag = port->state->port.tty->termios.c_cflag; in serial8250_console_restore()
3261 baud = serial8250_get_baud_rate(port, &termios, NULL); in serial8250_console_restore()
3262 quot = serial8250_get_divisor(port, baud, &frac); in serial8250_console_restore()
3264 serial8250_set_divisor(port, baud, quot, frac); in serial8250_console_restore()
3265 serial_port_out(port, UART_LCR, up->lcr); in serial8250_console_restore()
3281 struct uart_8250_em485 *em485 = up->em485; in serial8250_console_write()
3282 struct uart_port *port = &up->port; in serial8250_console_write()
3290 locked = spin_trylock_irqsave(&port->lock, flags); in serial8250_console_write()
3292 spin_lock_irqsave(&port->lock, flags); in serial8250_console_write()
3299 if (up->capabilities & UART_CAP_UUE) in serial8250_console_write()
3305 if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) { in serial8250_console_write()
3307 up->canary = 0; in serial8250_console_write()
3311 if (em485->tx_stopped) in serial8250_console_write()
3312 up->rs485_start_tx(up); in serial8250_console_write()
3313 mdelay(port->rs485.delay_rts_before_send); in serial8250_console_write()
3325 mdelay(port->rs485.delay_rts_after_send); in serial8250_console_write()
3326 if (em485->tx_stopped) in serial8250_console_write()
3327 up->rs485_stop_tx(up); in serial8250_console_write()
3339 if (up->msr_saved_flags) in serial8250_console_write()
3343 spin_unlock_irqrestore(&port->lock, flags); in serial8250_console_write()
3358 return (port->uartclk / 16) / quot; in probe_baud()
3363 int baud = 9600; in serial8250_console_setup() local
3369 if (!port->iobase && !port->membase) in serial8250_console_setup()
3370 return -ENODEV; in serial8250_console_setup()
3373 uart_parse_options(options, &baud, &parity, &bits, &flow); in serial8250_console_setup()
3375 baud = probe_baud(port); in serial8250_console_setup()
3377 ret = uart_set_options(port, port->cons, baud, parity, bits, flow); in serial8250_console_setup()
3381 if (port->dev) in serial8250_console_setup()
3382 pm_runtime_get_sync(port->dev); in serial8250_console_setup()
3389 if (port->dev) in serial8250_console_exit()
3390 pm_runtime_put_sync(port->dev); in serial8250_console_exit()