Lines Matching +full:up +full:-

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",
312 static int default_serial_dl_read(struct uart_8250_port *up) in default_serial_dl_read() argument
314 return serial_in(up, UART_DLL) | serial_in(up, UART_DLM) << 8; in default_serial_dl_read()
318 static void default_serial_dl_write(struct uart_8250_port *up, int value) in default_serial_dl_write() argument
320 serial_out(up, UART_DLL, value & 0xff); in default_serial_dl_write()
321 serial_out(up, UART_DLM, value >> 8 & 0xff); in default_serial_dl_write()
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()
370 static int au_serial_dl_read(struct uart_8250_port *up) in au_serial_dl_read() argument
372 return __raw_readl(up->port.membase + 0x28); in au_serial_dl_read()
375 static void au_serial_dl_write(struct uart_8250_port *up, int value) in au_serial_dl_write() argument
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()
460 struct uart_8250_port *up = up_to_u8250p(p); in set_io_from_upio() local
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()
530 static void serial_icr_write(struct uart_8250_port *up, int offset, int value) in serial_icr_write() argument
532 serial_out(up, UART_SCR, offset); in serial_icr_write()
533 serial_out(up, UART_ICR, value); in serial_icr_write()
536 static unsigned int serial_icr_read(struct uart_8250_port *up, int offset) in serial_icr_read() argument
540 serial_icr_write(up, UART_ACR, up->acr | UART_ACR_ICRRD); in serial_icr_read()
541 serial_out(up, UART_SCR, offset); in serial_icr_read()
542 value = serial_in(up, UART_ICR); 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
669 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_em485_config() local
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()
693 int ret = serial8250_em485_init(up); 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()
702 serial8250_em485_destroy(up); 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()
776 static int __enable_rsa(struct uart_8250_port *up) in __enable_rsa() argument
781 mode = serial_in(up, UART_RSA_MSR); in __enable_rsa()
785 serial_out(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); in __enable_rsa()
786 mode = serial_in(up, UART_RSA_MSR); in __enable_rsa()
791 up->port.uartclk = SERIAL_RSA_BAUD_BASE * 16; in __enable_rsa()
796 static void enable_rsa(struct uart_8250_port *up) in enable_rsa() argument
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()
801 __enable_rsa(up); 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()
805 serial_out(up, UART_RSA_FRR, 0); in enable_rsa()
815 static void disable_rsa(struct uart_8250_port *up) in disable_rsa() argument
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()
824 mode = serial_in(up, UART_RSA_MSR); in disable_rsa()
828 serial_out(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); in disable_rsa()
829 mode = serial_in(up, UART_RSA_MSR); 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()
844 static int size_fifo(struct uart_8250_port *up) in size_fifo() argument
850 old_lcr = serial_in(up, UART_LCR); in size_fifo()
851 serial_out(up, UART_LCR, 0); in size_fifo()
852 old_fcr = serial_in(up, UART_FCR); in size_fifo()
853 old_mcr = serial8250_in_MCR(up); in size_fifo()
854 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in size_fifo()
856 serial8250_out_MCR(up, UART_MCR_LOOP); in size_fifo()
857 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in size_fifo()
858 old_dl = serial_dl_read(up); in size_fifo()
859 serial_dl_write(up, 0x0001); in size_fifo()
860 serial_out(up, UART_LCR, 0x03); in size_fifo()
862 serial_out(up, UART_TX, count); in size_fifo()
863 mdelay(20);/* FIXME - schedule_timeout */ in size_fifo()
864 for (count = 0; (serial_in(up, UART_LSR) & UART_LSR_DR) && in size_fifo()
866 serial_in(up, UART_RX); in size_fifo()
867 serial_out(up, UART_FCR, old_fcr); in size_fifo()
868 serial8250_out_MCR(up, old_mcr); in size_fifo()
869 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in size_fifo()
870 serial_dl_write(up, old_dl); in size_fifo()
871 serial_out(up, UART_LCR, old_lcr); in size_fifo()
877 * Read UART ID using the divisor method - set DLL and DLM to zero
908 static void autoconfig_has_efr(struct uart_8250_port *up) in autoconfig_has_efr() argument
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()
921 * Semiconductor clone chips lock up if you try writing to the in autoconfig_has_efr()
934 up->acr = 0; in autoconfig_has_efr()
935 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig_has_efr()
936 serial_out(up, UART_EFR, UART_EFR_ECB); in autoconfig_has_efr()
937 serial_out(up, UART_LCR, 0x00); in autoconfig_has_efr()
938 id1 = serial_icr_read(up, UART_ID1); in autoconfig_has_efr()
939 id2 = serial_icr_read(up, UART_ID2); in autoconfig_has_efr()
940 id3 = serial_icr_read(up, UART_ID3); in autoconfig_has_efr()
941 rev = serial_icr_read(up, UART_REV); in autoconfig_has_efr()
947 up->port.type = PORT_16C950; 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()
967 id1 = autoconfig_read_divisor_id(up); 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()
985 if (size_fifo(up) == 64) 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
996 static void autoconfig_8250(struct uart_8250_port *up) in autoconfig_8250() argument
1000 up->port.type = PORT_8250; in autoconfig_8250()
1002 scratch = serial_in(up, UART_SCR); in autoconfig_8250()
1003 serial_out(up, UART_SCR, 0xa5); in autoconfig_8250()
1004 status1 = serial_in(up, UART_SCR); in autoconfig_8250()
1005 serial_out(up, UART_SCR, 0x5a); in autoconfig_8250()
1006 status2 = serial_in(up, UART_SCR); in autoconfig_8250()
1007 serial_out(up, UART_SCR, scratch); in autoconfig_8250()
1010 up->port.type = PORT_16450; in autoconfig_8250()
1013 static int broken_efr(struct uart_8250_port *up) in broken_efr() argument
1018 * http://linux.derkeiler.com/Mailing-Lists/Kernel/2004-11/4812.html in broken_efr()
1020 if (autoconfig_read_divisor_id(up) == 0x0201 && size_fifo(up) == 16) in broken_efr()
1032 static void autoconfig_16550a(struct uart_8250_port *up) in autoconfig_16550a() argument
1037 up->port.type = PORT_16550A; in autoconfig_16550a()
1038 up->capabilities |= UART_CAP_FIFO; in autoconfig_16550a()
1047 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in autoconfig_16550a()
1048 if (serial_in(up, UART_EFR) == 0) { in autoconfig_16550a()
1049 serial_out(up, UART_EFR, 0xA8); in autoconfig_16550a()
1050 if (serial_in(up, UART_EFR) != 0) { in autoconfig_16550a()
1052 up->port.type = PORT_16650; in autoconfig_16550a()
1053 up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP; in autoconfig_16550a()
1055 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1056 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in autoconfig_16550a()
1058 status1 = serial_in(up, UART_IIR) >> 5; in autoconfig_16550a()
1059 serial_out(up, UART_FCR, 0); in autoconfig_16550a()
1060 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1063 up->port.type = PORT_16550A_FSL64; in autoconfig_16550a()
1067 serial_out(up, UART_EFR, 0); in autoconfig_16550a()
1075 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig_16550a()
1076 if (serial_in(up, UART_EFR) == 0 && !broken_efr(up)) { in autoconfig_16550a()
1078 autoconfig_has_efr(up); in autoconfig_16550a()
1087 * it's changed. If so, set baud_base in EXCR2 to 921600. -- dwmw2 in autoconfig_16550a()
1089 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1090 status1 = serial8250_in_MCR(up); in autoconfig_16550a()
1091 serial_out(up, UART_LCR, 0xE0); in autoconfig_16550a()
1092 status2 = serial_in(up, 0x02); /* EXCR1 */ in autoconfig_16550a()
1095 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1096 serial8250_out_MCR(up, status1 ^ UART_MCR_LOOP); in autoconfig_16550a()
1097 serial_out(up, UART_LCR, 0xE0); in autoconfig_16550a()
1098 status2 = serial_in(up, 0x02); /* EXCR1 */ in autoconfig_16550a()
1099 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1100 serial8250_out_MCR(up, status1); in autoconfig_16550a()
1105 serial_out(up, UART_LCR, 0xE0); in autoconfig_16550a()
1107 quot = serial_dl_read(up); in autoconfig_16550a()
1110 if (ns16550a_goto_highspeed(up)) in autoconfig_16550a()
1111 serial_dl_write(up, quot); in autoconfig_16550a()
1113 serial_out(up, UART_LCR, 0); 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()
1128 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1129 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); in autoconfig_16550a()
1130 status1 = serial_in(up, UART_IIR) >> 5; in autoconfig_16550a()
1131 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig_16550a()
1132 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in autoconfig_16550a()
1133 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); in autoconfig_16550a()
1134 status2 = serial_in(up, UART_IIR) >> 5; in autoconfig_16550a()
1135 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig_16550a()
1136 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1141 up->port.type = PORT_16750; in autoconfig_16550a()
1142 up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP; in autoconfig_16550a()
1154 iersave = serial_in(up, UART_IER); in autoconfig_16550a()
1155 serial_out(up, UART_IER, iersave & ~UART_IER_UUE); in autoconfig_16550a()
1156 if (!(serial_in(up, UART_IER) & UART_IER_UUE)) { in autoconfig_16550a()
1161 serial_out(up, UART_IER, iersave | UART_IER_UUE); in autoconfig_16550a()
1162 if (serial_in(up, UART_IER) & UART_IER_UUE) { in autoconfig_16550a()
1168 up->port.type = PORT_XSCALE; in autoconfig_16550a()
1169 up->capabilities |= UART_CAP_UUE | UART_CAP_RTOIE; in autoconfig_16550a()
1179 serial_out(up, UART_IER, iersave); 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()
1198 static void autoconfig(struct uart_8250_port *up) in autoconfig() argument
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()
1235 scratch = serial_in(up, UART_IER); in autoconfig()
1236 serial_out(up, UART_IER, 0); in autoconfig()
1244 scratch2 = serial_in(up, UART_IER) & 0x0f; in autoconfig()
1245 serial_out(up, UART_IER, 0x0F); in autoconfig()
1249 scratch3 = serial_in(up, UART_IER) & 0x0f; in autoconfig()
1250 serial_out(up, UART_IER, scratch); in autoconfig()
1255 spin_unlock_irqrestore(&port->lock, flags); in autoconfig()
1262 save_mcr = serial8250_in_MCR(up); in autoconfig()
1263 save_lcr = serial_in(up, UART_LCR); in autoconfig()
1272 * that conflicts with COM 1-4 --- we hope! in autoconfig()
1274 if (!(port->flags & UPF_SKIP_TEST)) { in autoconfig()
1275 serial8250_out_MCR(up, UART_MCR_LOOP | 0x0A); in autoconfig()
1276 status1 = serial_in(up, UART_MSR) & 0xF0; in autoconfig()
1277 serial8250_out_MCR(up, save_mcr); in autoconfig()
1279 spin_unlock_irqrestore(&port->lock, flags); in autoconfig()
1295 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig()
1296 serial_out(up, UART_EFR, 0); in autoconfig()
1297 serial_out(up, UART_LCR, 0); in autoconfig()
1299 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig()
1300 scratch = serial_in(up, UART_IIR) >> 6; in autoconfig()
1304 autoconfig_8250(up); in autoconfig()
1307 port->type = PORT_UNKNOWN; in autoconfig()
1310 port->type = PORT_16550; in autoconfig()
1313 autoconfig_16550a(up); in autoconfig()
1321 if (port->type == PORT_16550A && up->probe & UART_PROBE_RSA && in autoconfig()
1322 __enable_rsa(up)) in autoconfig()
1323 port->type = PORT_RSA; in autoconfig()
1326 serial_out(up, UART_LCR, save_lcr); 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()
1341 serial_out(up, UART_RSA_FRR, 0); in autoconfig()
1343 serial8250_out_MCR(up, save_mcr); in autoconfig()
1344 serial8250_clear_fifos(up); in autoconfig()
1345 serial_in(up, UART_RX); in autoconfig()
1346 if (up->capabilities & UART_CAP_UUE) in autoconfig()
1347 serial_out(up, UART_IER, UART_IER_UUE); in autoconfig()
1349 serial_out(up, UART_IER, 0); in autoconfig()
1352 spin_unlock_irqrestore(&port->lock, flags); in autoconfig()
1357 if (port->type == PORT_16550A && port->iotype == UPIO_PORT) in autoconfig()
1358 fintek_8250_probe(up); 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()
1369 static void autoconfig_irq(struct uart_8250_port *up) in autoconfig_irq() argument
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()
1390 save_mcr = serial8250_in_MCR(up); in autoconfig_irq()
1391 save_ier = serial_in(up, UART_IER); in autoconfig_irq()
1392 serial8250_out_MCR(up, UART_MCR_OUT1 | UART_MCR_OUT2); in autoconfig_irq()
1395 serial8250_out_MCR(up, 0); in autoconfig_irq()
1397 if (port->flags & UPF_FOURPORT) { in autoconfig_irq()
1398 serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS); in autoconfig_irq()
1400 serial8250_out_MCR(up, in autoconfig_irq()
1403 serial_out(up, UART_IER, 0x0f); /* enable all intrs */ in autoconfig_irq()
1404 serial_in(up, UART_LSR); in autoconfig_irq()
1405 serial_in(up, UART_RX); in autoconfig_irq()
1406 serial_in(up, UART_IIR); in autoconfig_irq()
1407 serial_in(up, UART_MSR); in autoconfig_irq()
1408 serial_out(up, UART_TX, 0xFF); in autoconfig_irq()
1412 serial8250_out_MCR(up, save_mcr); in autoconfig_irq()
1413 serial_out(up, UART_IER, save_ier); in autoconfig_irq()
1415 if (port->flags & UPF_FOURPORT) in autoconfig_irq()
1421 port->irq = (irq > 0) ? irq : 0; in autoconfig_irq()
1426 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_stop_rx() local
1428 serial8250_rpm_get(up); in serial8250_stop_rx()
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()
1434 serial8250_rpm_put(up); 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()
1544 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_stop_tx() local
1546 serial8250_rpm_get(up); in serial8250_stop_tx()
1547 __stop_tx(up); in serial8250_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()
1556 serial8250_rpm_put(up); in serial8250_stop_tx()
1561 struct uart_8250_port *up = up_to_u8250p(port); in __start_tx() local
1563 if (up->dma && !up->dma->tx_dma(up)) in __start_tx()
1566 if (serial8250_set_THRI(up)) { in __start_tx()
1567 if (up->bugs & UART_BUG_TXEN) { in __start_tx()
1570 lsr = serial_in(up, UART_LSR); in __start_tx()
1571 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; in __start_tx()
1573 serial8250_tx_chars(up); 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
1588 * @up: uart 8250 port
1596 void serial8250_em485_start_tx(struct uart_8250_port *up) in serial8250_em485_start_tx() argument
1598 unsigned char mcr = serial8250_in_MCR(up); in serial8250_em485_start_tx()
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()
1607 serial8250_out_MCR(up, mcr); in serial8250_em485_start_tx()
1613 struct uart_8250_port *up = up_to_u8250p(port); in start_tx_rs485() local
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()
1654 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_start_tx() local
1655 struct uart_8250_em485 *em485 = up->em485; in serial8250_start_tx()
1657 serial8250_rpm_get_tx(up); 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()
1681 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_disable_ms() local
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()
1695 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_enable_ms() local
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()
1705 serial8250_rpm_get(up); in serial8250_enable_ms()
1706 serial_port_out(port, UART_IER, up->ier); in serial8250_enable_ms()
1707 serial8250_rpm_put(up); in serial8250_enable_ms()
1710 void serial8250_read_char(struct uart_8250_port *up, unsigned char lsr) in serial8250_read_char() argument
1712 struct uart_port *port = &up->port; in serial8250_read_char()
1717 ch = serial_in(up, UART_RX); 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()
1777 unsigned char serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) in serial8250_rx_chars() argument
1779 struct uart_port *port = &up->port; in serial8250_rx_chars()
1783 serial8250_read_char(up, lsr); in serial8250_rx_chars()
1784 if (--max_count == 0) in serial8250_rx_chars()
1786 lsr = serial_in(up, UART_LSR); in serial8250_rx_chars()
1789 tty_flip_buffer_push(&port->state->port); in serial8250_rx_chars()
1794 void serial8250_tx_chars(struct uart_8250_port *up) in serial8250_tx_chars() argument
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()
1811 __stop_tx(up); 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()
1823 (serial_in(up, UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY) 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()
1827 !(serial_in(up, UART_LSR) & UART_LSR_THRE)) 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()
1840 __stop_tx(up); in serial8250_tx_chars()
1845 unsigned int serial8250_modem_status(struct uart_8250_port *up) in serial8250_modem_status() argument
1847 struct uart_port *port = &up->port; in serial8250_modem_status()
1848 unsigned int status = serial_in(up, UART_MSR); 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()
1870 static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir) in handle_rx_dma() argument
1874 serial8250_rx_dma_flush(up); in handle_rx_dma()
1879 return up->dma->rx_dma(up); in handle_rx_dma()
1889 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_handle_irq() local
1895 spin_lock_irqsave(&port->lock, flags); 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()
1914 status = serial8250_rx_chars(up, status); in serial8250_handle_irq()
1916 serial8250_modem_status(up); 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()
1919 serial8250_tx_chars(up); in serial8250_handle_irq()
1928 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_default_handle_irq() local
1932 serial8250_rpm_get(up); in serial8250_default_handle_irq()
1937 serial8250_rpm_put(up); in serial8250_default_handle_irq()
1945 * has space available. Load it up with tx_loadsz bytes.
1952 /* TX Threshold IRQ triggered so load up FIFO */ in serial8250_tx_threshold_handle_irq()
1954 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_tx_threshold_handle_irq() local
1956 spin_lock_irqsave(&port->lock, flags); in serial8250_tx_threshold_handle_irq()
1957 serial8250_tx_chars(up); in serial8250_tx_threshold_handle_irq()
1958 spin_unlock_irqrestore(&port->lock, flags); in serial8250_tx_threshold_handle_irq()
1967 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_tx_empty() local
1971 serial8250_rpm_get(up); in serial8250_tx_empty()
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()
1978 serial8250_rpm_put(up); in serial8250_tx_empty()
1985 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_get_mctrl() local
1989 serial8250_rpm_get(up); in serial8250_do_get_mctrl()
1990 status = serial8250_modem_status(up); in serial8250_do_get_mctrl()
1991 serial8250_rpm_put(up); in serial8250_do_get_mctrl()
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()
2010 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_set_mctrl() local
2013 if (port->rs485.flags & SER_RS485_ENABLED) { in serial8250_do_set_mctrl()
2014 if (serial8250_in_MCR(up) & UART_MCR_RTS) in serial8250_do_set_mctrl()
2022 mcr = (mcr & up->mcr_mask) | up->mcr_force | up->mcr; in serial8250_do_set_mctrl()
2024 serial8250_out_MCR(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()
2038 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_break_ctl() local
2041 serial8250_rpm_get(up); in serial8250_break_ctl()
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()
2049 serial8250_rpm_put(up); in serial8250_break_ctl()
2055 static void wait_for_xmitr(struct uart_8250_port *up, int bits) in wait_for_xmitr() argument
2059 /* Wait up to 10ms for the character(s) to be sent. */ in wait_for_xmitr()
2061 status = serial_in(up, UART_LSR); in wait_for_xmitr()
2063 up->lsr_saved_flags |= status & LSR_SAVE_FLAGS; in wait_for_xmitr()
2067 if (--tmout == 0) in wait_for_xmitr()
2073 /* Wait up to 1s for flow control if necessary */ 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()
2076 unsigned int msr = serial_in(up, UART_MSR); in wait_for_xmitr()
2077 up->msr_saved_flags |= msr & MSR_SAVE_FLAGS; in wait_for_xmitr()
2094 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_get_poll_char() local
2098 serial8250_rpm_get(up); in serial8250_get_poll_char()
2109 serial8250_rpm_put(up); in serial8250_get_poll_char()
2118 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_put_poll_char() local
2120 serial8250_rpm_get(up); in serial8250_put_poll_char()
2125 if (up->capabilities & UART_CAP_UUE) in serial8250_put_poll_char()
2130 wait_for_xmitr(up, BOTH_EMPTY); in serial8250_put_poll_char()
2140 wait_for_xmitr(up, BOTH_EMPTY); in serial8250_put_poll_char()
2142 serial8250_rpm_put(up); in serial8250_put_poll_char()
2149 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_startup() local
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()
2165 serial8250_rpm_get(up); in serial8250_do_startup()
2166 if (port->type == PORT_16C950) { in serial8250_do_startup()
2167 /* Wake up and initialize UART */ in serial8250_do_startup()
2168 up->acr = 0; in serial8250_do_startup()
2173 serial_icr_write(up, UART_CSR, 0); /* Reset the UART */ in serial8250_do_startup()
2179 if (port->type == PORT_DA830) { in serial8250_do_startup()
2192 if (port->type == PORT_NPCM) { in serial8250_do_startup()
2203 * If this is an RSA port, see if we can kick it up to the in serial8250_do_startup()
2206 enable_rsa(up); in serial8250_do_startup()
2213 serial8250_clear_fifos(up); 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()
2241 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial8250_do_startup()
2243 fctr = serial_in(up, UART_FCTR) & ~(UART_FCTR_RX|UART_FCTR_TX); 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()
2292 wait_for_xmitr(up, UART_LSR_THRE); 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()
2395 else if (serial8250_request_dma(up)) 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()
2421 serial8250_rpm_put(up); in serial8250_do_startup()
2428 if (port->startup) in serial8250_startup()
2429 return port->startup(port); in serial8250_startup()
2435 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_shutdown() local
2438 serial8250_rpm_get(up); in serial8250_do_shutdown()
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()
2450 serial8250_release_dma(up); 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()
2468 serial8250_clear_fifos(up); in serial8250_do_shutdown()
2474 disable_rsa(up); in serial8250_do_shutdown()
2482 serial8250_rpm_put(up); 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()
2497 static unsigned int npcm_get_divisor(struct uart_8250_port *up, 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()
2509 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_get_divisor() local
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()
2531 if (up->bugs & UART_BUG_QUOT && (quot & 0xff) == 0) in serial8250_do_get_divisor()
2541 if (port->get_divisor) in serial8250_get_divisor()
2542 return port->get_divisor(port, baud, frac); in serial8250_get_divisor()
2547 static unsigned char serial8250_compute_lcr(struct uart_8250_port *up, in serial8250_compute_lcr() argument
2572 if (up->bugs & UART_BUG_PARITY) in serial8250_compute_lcr()
2573 up->fifo_bug = true; in serial8250_compute_lcr()
2588 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_set_divisor() local
2591 if (is_omap1510_8250(up)) { 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()
2608 serial_dl_write(up, quot); in serial8250_do_set_divisor()
2615 if (port->set_divisor) in serial8250_set_divisor()
2616 port->set_divisor(port, baud, quot, quot_frac); in serial8250_set_divisor()
2625 unsigned int tolerance = port->uartclk / 100; 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()
2645 struct uart_8250_port *up = up_to_u8250p(port); 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()
2665 serial8250_rpm_get(up); 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()
2671 serial_port_out(port, UART_LCR, up->lcr); in serial8250_update_uartclk()
2673 spin_unlock_irqrestore(&port->lock, flags); in serial8250_update_uartclk()
2674 serial8250_rpm_put(up); in serial8250_update_uartclk()
2677 mutex_unlock(&port->state->port.mutex); in serial8250_update_uartclk()
2685 struct uart_8250_port *up = up_to_u8250p(port); 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()
2705 serial8250_rpm_get(up); 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()
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()
2811 serial8250_rpm_put(up); 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()
2893 static int serial8250_request_std_resource(struct uart_8250_port *up) in serial8250_request_std_resource() argument
2895 unsigned int size = serial8250_port_size(up); in serial8250_request_std_resource()
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()
2932 static void serial8250_release_std_resource(struct uart_8250_port *up) in serial8250_release_std_resource() argument
2934 unsigned int size = serial8250_port_size(up); in serial8250_release_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()
2964 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_release_port() local
2966 serial8250_release_std_resource(up); in serial8250_release_port()
2971 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_request_port() local
2973 return serial8250_request_std_resource(up); in serial8250_request_port()
2976 static int fcr_get_rxtrig_bytes(struct uart_8250_port *up) in fcr_get_rxtrig_bytes() argument
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()
2986 static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, unsigned char bytes) in bytes_to_fcr_rxtrig() argument
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()
3007 struct uart_8250_port *up = up_to_u8250p(uport); in do_get_rxtrig() local
3009 if (!(up->capabilities & UART_CAP_FIFO) || uport->fifosize <= 1) in do_get_rxtrig()
3010 return -EINVAL; in do_get_rxtrig()
3012 return fcr_get_rxtrig_bytes(up); 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()
3043 struct uart_8250_port *up = up_to_u8250p(uport); in do_set_rxtrig() local
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()
3050 rxtrig = bytes_to_fcr_rxtrig(up, bytes); in do_set_rxtrig()
3054 serial8250_clear_fifos(up); 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()
3104 static void register_dev_spec_attr_grp(struct uart_8250_port *up) in register_dev_spec_attr_grp() argument
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()
3114 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_config_port() local
3121 ret = serial8250_request_std_resource(up); in serial8250_config_port()
3125 if (port->iotype != up->cur_iotype) in serial8250_config_port()
3129 autoconfig(up); 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()
3143 autoconfig_irq(up); in serial8250_config_port()
3145 if (port->type == PORT_UNKNOWN) in serial8250_config_port()
3146 serial8250_release_std_resource(up); in serial8250_config_port()
3148 register_dev_spec_attr_grp(up); 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()
3199 void serial8250_init_port(struct uart_8250_port *up) in serial8250_init_port() argument
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()
3211 void serial8250_set_defaults(struct uart_8250_port *up) in serial8250_set_defaults() argument
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()
3242 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_console_putchar() local
3244 wait_for_xmitr(up, UART_LSR_THRE); in serial8250_console_putchar()
3249 * Restore serial console when h/w power-off detected
3251 static void serial8250_console_restore(struct uart_8250_port *up) in serial8250_console_restore() argument
3253 struct uart_port *port = &up->port; in serial8250_console_restore()
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()
3265 serial_port_out(port, UART_LCR, up->lcr); in serial8250_console_restore()
3266 serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS); in serial8250_console_restore()
3276 * Thus, we assume the function is called when device is powered up.
3278 void serial8250_console_write(struct uart_8250_port *up, const char *s, in serial8250_console_write() argument
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()
3306 serial8250_console_restore(up); 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()
3322 wait_for_xmitr(up, BOTH_EMPTY); 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()
3340 serial8250_modem_status(up); in serial8250_console_write()
3343 spin_unlock_irqrestore(&port->lock, flags); in serial8250_console_write()
3358 return (port->uartclk / 16) / quot; in probe_baud()
3369 if (!port->iobase && !port->membase) in serial8250_console_setup()
3370 return -ENODEV; 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()