Lines Matching full:up
325 static u32 default_serial_dl_read(struct uart_8250_port *up) in default_serial_dl_read() argument
328 unsigned char dll = serial_in(up, UART_DLL); in default_serial_dl_read()
329 unsigned char dlm = serial_in(up, UART_DLM); in default_serial_dl_read()
335 static void default_serial_dl_write(struct uart_8250_port *up, u32 value) in default_serial_dl_write() argument
337 serial_out(up, UART_DLL, value & 0xff); in default_serial_dl_write()
338 serial_out(up, UART_DLM, value >> 8 & 0xff); in default_serial_dl_write()
419 struct uart_8250_port *up = up_to_u8250p(p); in set_io_from_upio() local
421 up->dl_read = default_serial_dl_read; in set_io_from_upio()
422 up->dl_write = default_serial_dl_write; in set_io_from_upio()
456 up->cur_iotype = p->iotype; in set_io_from_upio()
613 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_em485_config() local
620 return serial8250_em485_init(up); in serial8250_em485_config()
622 serial8250_em485_destroy(up); in serial8250_em485_config()
694 static void serial8250_clear_IER(struct uart_8250_port *up) in serial8250_clear_IER() argument
696 if (up->capabilities & UART_CAP_UUE) in serial8250_clear_IER()
697 serial_out(up, UART_IER, UART_IER_UUE); in serial8250_clear_IER()
699 serial_out(up, UART_IER, 0); in serial8250_clear_IER()
707 static int __enable_rsa(struct uart_8250_port *up) in __enable_rsa() argument
712 mode = serial_in(up, UART_RSA_MSR); in __enable_rsa()
716 serial_out(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); in __enable_rsa()
717 mode = serial_in(up, UART_RSA_MSR); in __enable_rsa()
722 up->port.uartclk = SERIAL_RSA_BAUD_BASE * 16; in __enable_rsa()
727 static void enable_rsa(struct uart_8250_port *up) in enable_rsa() argument
729 if (up->port.type == PORT_RSA) { in enable_rsa()
730 if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) { in enable_rsa()
731 uart_port_lock_irq(&up->port); in enable_rsa()
732 __enable_rsa(up); in enable_rsa()
733 uart_port_unlock_irq(&up->port); in enable_rsa()
735 if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) in enable_rsa()
736 serial_out(up, UART_RSA_FRR, 0); in enable_rsa()
746 static void disable_rsa(struct uart_8250_port *up) in disable_rsa() argument
751 if (up->port.type == PORT_RSA && in disable_rsa()
752 up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) { in disable_rsa()
753 uart_port_lock_irq(&up->port); in disable_rsa()
755 mode = serial_in(up, UART_RSA_MSR); in disable_rsa()
759 serial_out(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); in disable_rsa()
760 mode = serial_in(up, UART_RSA_MSR); in disable_rsa()
765 up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16; in disable_rsa()
766 uart_port_unlock_irq(&up->port); in disable_rsa()
775 static int size_fifo(struct uart_8250_port *up) in size_fifo() argument
781 old_lcr = serial_in(up, UART_LCR); in size_fifo()
782 serial_out(up, UART_LCR, 0); in size_fifo()
783 old_fcr = serial_in(up, UART_FCR); in size_fifo()
784 old_mcr = serial8250_in_MCR(up); in size_fifo()
785 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in size_fifo()
787 serial8250_out_MCR(up, UART_MCR_LOOP); in size_fifo()
788 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in size_fifo()
789 old_dl = serial_dl_read(up); in size_fifo()
790 serial_dl_write(up, 0x0001); in size_fifo()
791 serial_out(up, UART_LCR, UART_LCR_WLEN8); in size_fifo()
793 serial_out(up, UART_TX, count); in size_fifo()
795 for (count = 0; (serial_in(up, UART_LSR) & UART_LSR_DR) && in size_fifo()
797 serial_in(up, UART_RX); in size_fifo()
798 serial_out(up, UART_FCR, old_fcr); in size_fifo()
799 serial8250_out_MCR(up, old_mcr); in size_fifo()
800 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in size_fifo()
801 serial_dl_write(up, old_dl); in size_fifo()
802 serial_out(up, UART_LCR, old_lcr); in size_fifo()
839 static void autoconfig_has_efr(struct uart_8250_port *up) in autoconfig_has_efr() argument
846 up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP; in autoconfig_has_efr()
852 * Semiconductor clone chips lock up if you try writing to the in autoconfig_has_efr()
865 up->acr = 0; in autoconfig_has_efr()
866 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig_has_efr()
867 serial_out(up, UART_EFR, UART_EFR_ECB); in autoconfig_has_efr()
868 serial_out(up, UART_LCR, 0x00); in autoconfig_has_efr()
869 id1 = serial_icr_read(up, UART_ID1); in autoconfig_has_efr()
870 id2 = serial_icr_read(up, UART_ID2); in autoconfig_has_efr()
871 id3 = serial_icr_read(up, UART_ID3); in autoconfig_has_efr()
872 rev = serial_icr_read(up, UART_REV); in autoconfig_has_efr()
878 up->port.type = PORT_16C950; in autoconfig_has_efr()
886 up->bugs |= UART_BUG_QUOT; in autoconfig_has_efr()
898 id1 = autoconfig_read_divisor_id(up); in autoconfig_has_efr()
903 up->port.type = PORT_16850; in autoconfig_has_efr()
916 if (size_fifo(up) == 64) in autoconfig_has_efr()
917 up->port.type = PORT_16654; in autoconfig_has_efr()
919 up->port.type = PORT_16650V2; in autoconfig_has_efr()
927 static void autoconfig_8250(struct uart_8250_port *up) in autoconfig_8250() argument
931 up->port.type = PORT_8250; in autoconfig_8250()
933 scratch = serial_in(up, UART_SCR); in autoconfig_8250()
934 serial_out(up, UART_SCR, 0xa5); in autoconfig_8250()
935 status1 = serial_in(up, UART_SCR); in autoconfig_8250()
936 serial_out(up, UART_SCR, 0x5a); in autoconfig_8250()
937 status2 = serial_in(up, UART_SCR); in autoconfig_8250()
938 serial_out(up, UART_SCR, scratch); in autoconfig_8250()
941 up->port.type = PORT_16450; in autoconfig_8250()
944 static int broken_efr(struct uart_8250_port *up) in broken_efr() argument
951 if (autoconfig_read_divisor_id(up) == 0x0201 && size_fifo(up) == 16) in broken_efr()
963 static void autoconfig_16550a(struct uart_8250_port *up) in autoconfig_16550a() argument
969 lockdep_assert_held_once(&up->port.lock); in autoconfig_16550a()
971 up->port.type = PORT_16550A; in autoconfig_16550a()
972 up->capabilities |= UART_CAP_FIFO; in autoconfig_16550a()
975 !(up->port.flags & UPF_FULL_PROBE)) in autoconfig_16550a()
982 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in autoconfig_16550a()
983 if (serial_in(up, UART_EFR) == 0) { in autoconfig_16550a()
984 serial_out(up, UART_EFR, 0xA8); in autoconfig_16550a()
985 if (serial_in(up, UART_EFR) != 0) { in autoconfig_16550a()
987 up->port.type = PORT_16650; in autoconfig_16550a()
988 up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP; in autoconfig_16550a()
990 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
991 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in autoconfig_16550a()
993 status1 = serial_in(up, UART_IIR) & UART_IIR_FIFO_ENABLED_16750; in autoconfig_16550a()
994 serial_out(up, UART_FCR, 0); in autoconfig_16550a()
995 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
998 up->port.type = PORT_16550A_FSL64; in autoconfig_16550a()
1002 serial_out(up, UART_EFR, 0); in autoconfig_16550a()
1010 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig_16550a()
1011 if (serial_in(up, UART_EFR) == 0 && !broken_efr(up)) { in autoconfig_16550a()
1013 autoconfig_has_efr(up); in autoconfig_16550a()
1024 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1025 status1 = serial8250_in_MCR(up); in autoconfig_16550a()
1026 serial_out(up, UART_LCR, 0xE0); in autoconfig_16550a()
1027 status2 = serial_in(up, 0x02); /* EXCR1 */ in autoconfig_16550a()
1030 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1031 serial8250_out_MCR(up, status1 ^ UART_MCR_LOOP); in autoconfig_16550a()
1032 serial_out(up, UART_LCR, 0xE0); in autoconfig_16550a()
1033 status2 = serial_in(up, 0x02); /* EXCR1 */ in autoconfig_16550a()
1034 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1035 serial8250_out_MCR(up, status1); in autoconfig_16550a()
1040 serial_out(up, UART_LCR, 0xE0); in autoconfig_16550a()
1042 quot = serial_dl_read(up); in autoconfig_16550a()
1045 if (ns16550a_goto_highspeed(up)) in autoconfig_16550a()
1046 serial_dl_write(up, quot); in autoconfig_16550a()
1048 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1050 up->port.uartclk = 921600*16; in autoconfig_16550a()
1051 up->port.type = PORT_NS16550A; in autoconfig_16550a()
1052 up->capabilities |= UART_NATSEMI; in autoconfig_16550a()
1063 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1064 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); in autoconfig_16550a()
1065 status1 = serial_in(up, UART_IIR) & UART_IIR_FIFO_ENABLED_16750; in autoconfig_16550a()
1066 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig_16550a()
1068 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in autoconfig_16550a()
1069 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); in autoconfig_16550a()
1070 status2 = serial_in(up, UART_IIR) & UART_IIR_FIFO_ENABLED_16750; in autoconfig_16550a()
1071 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig_16550a()
1073 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1079 up->port.type = PORT_16750; in autoconfig_16550a()
1080 up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP; in autoconfig_16550a()
1092 iersave = serial_in(up, UART_IER); in autoconfig_16550a()
1093 serial_out(up, UART_IER, iersave & ~UART_IER_UUE); in autoconfig_16550a()
1094 if (!(serial_in(up, UART_IER) & UART_IER_UUE)) { in autoconfig_16550a()
1099 serial_out(up, UART_IER, iersave | UART_IER_UUE); in autoconfig_16550a()
1100 if (serial_in(up, UART_IER) & UART_IER_UUE) { in autoconfig_16550a()
1106 up->port.type = PORT_XSCALE; in autoconfig_16550a()
1107 up->capabilities |= UART_CAP_UUE | UART_CAP_RTOIE; in autoconfig_16550a()
1117 serial_out(up, UART_IER, iersave); in autoconfig_16550a()
1123 if (up->port.type == PORT_16550A && size_fifo(up) == 64) { in autoconfig_16550a()
1124 up->port.type = PORT_U6_16550A; in autoconfig_16550a()
1125 up->capabilities |= UART_CAP_AFE; in autoconfig_16550a()
1136 static void autoconfig(struct uart_8250_port *up) in autoconfig() argument
1140 struct uart_port *port = &up->port; in autoconfig()
1158 up->capabilities = 0; in autoconfig()
1159 up->bugs = 0; in autoconfig()
1175 scratch = serial_in(up, UART_IER); in autoconfig()
1176 serial_out(up, UART_IER, 0); in autoconfig()
1184 scratch2 = serial_in(up, UART_IER) & UART_IER_ALL_INTR; in autoconfig()
1185 serial_out(up, UART_IER, UART_IER_ALL_INTR); in autoconfig()
1189 scratch3 = serial_in(up, UART_IER) & UART_IER_ALL_INTR; in autoconfig()
1190 serial_out(up, UART_IER, scratch); in autoconfig()
1202 save_mcr = serial8250_in_MCR(up); in autoconfig()
1203 save_lcr = serial_in(up, UART_LCR); in autoconfig()
1215 serial8250_out_MCR(up, UART_MCR_LOOP | UART_MCR_OUT2 | UART_MCR_RTS); in autoconfig()
1216 status1 = serial_in(up, UART_MSR) & UART_MSR_STATUS_BITS; in autoconfig()
1217 serial8250_out_MCR(up, save_mcr); in autoconfig()
1235 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig()
1236 serial_out(up, UART_EFR, 0); in autoconfig()
1237 serial_out(up, UART_LCR, 0); in autoconfig()
1239 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig()
1241 switch (serial_in(up, UART_IIR) & UART_IIR_FIFO_ENABLED) { in autoconfig()
1243 autoconfig_8250(up); in autoconfig()
1249 autoconfig_16550a(up); in autoconfig()
1260 if (port->type == PORT_16550A && up->probe & UART_PROBE_RSA && in autoconfig()
1261 __enable_rsa(up)) in autoconfig()
1265 serial_out(up, UART_LCR, save_lcr); in autoconfig()
1267 port->fifosize = uart_config[up->port.type].fifo_size; in autoconfig()
1268 old_capabilities = up->capabilities; in autoconfig()
1269 up->capabilities = uart_config[port->type].flags; in autoconfig()
1270 up->tx_loadsz = uart_config[port->type].tx_loadsz; in autoconfig()
1280 serial_out(up, UART_RSA_FRR, 0); in autoconfig()
1282 serial8250_out_MCR(up, save_mcr); in autoconfig()
1283 serial8250_clear_fifos(up); in autoconfig()
1284 serial_in(up, UART_RX); in autoconfig()
1285 serial8250_clear_IER(up); in autoconfig()
1294 fintek_8250_probe(up); in autoconfig()
1296 if (up->capabilities != old_capabilities) { in autoconfig()
1298 old_capabilities, up->capabilities); in autoconfig()
1305 static void autoconfig_irq(struct uart_8250_port *up) in autoconfig_irq() argument
1307 struct uart_port *port = &up->port; in autoconfig_irq()
1323 save_mcr = serial8250_in_MCR(up); in autoconfig_irq()
1326 save_ier = serial_in(up, UART_IER); in autoconfig_irq()
1328 serial8250_out_MCR(up, UART_MCR_OUT1 | UART_MCR_OUT2); in autoconfig_irq()
1331 serial8250_out_MCR(up, 0); in autoconfig_irq()
1334 serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS); in autoconfig_irq()
1336 serial8250_out_MCR(up, in autoconfig_irq()
1341 serial_out(up, UART_IER, UART_IER_ALL_INTR); in autoconfig_irq()
1343 serial_in(up, UART_LSR); in autoconfig_irq()
1344 serial_in(up, UART_RX); in autoconfig_irq()
1345 serial_in(up, UART_IIR); in autoconfig_irq()
1346 serial_in(up, UART_MSR); in autoconfig_irq()
1347 serial_out(up, UART_TX, 0xFF); in autoconfig_irq()
1351 serial8250_out_MCR(up, save_mcr); in autoconfig_irq()
1354 serial_out(up, UART_IER, save_ier); in autoconfig_irq()
1365 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_stop_rx() local
1370 serial8250_rpm_get(up); in serial8250_stop_rx()
1372 up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); in serial8250_stop_rx()
1373 up->port.read_status_mask &= ~UART_LSR_DR; in serial8250_stop_rx()
1374 serial_port_out(port, UART_IER, up->ier); in serial8250_stop_rx()
1376 serial8250_rpm_put(up); in serial8250_stop_rx()
1500 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_stop_tx() local
1502 serial8250_rpm_get(up); in serial8250_stop_tx()
1503 __stop_tx(up); in serial8250_stop_tx()
1509 up->acr |= UART_ACR_TXDIS; in serial8250_stop_tx()
1510 serial_icr_write(up, UART_ACR, up->acr); in serial8250_stop_tx()
1512 serial8250_rpm_put(up); in serial8250_stop_tx()
1517 struct uart_8250_port *up = up_to_u8250p(port); in __start_tx() local
1519 if (up->dma && !up->dma->tx_dma(up)) in __start_tx()
1522 if (serial8250_set_THRI(up)) { in __start_tx()
1523 if (up->bugs & UART_BUG_TXEN) { in __start_tx()
1524 u16 lsr = serial_lsr_in(up); in __start_tx()
1527 serial8250_tx_chars(up); in __start_tx()
1534 if (port->type == PORT_16C950 && up->acr & UART_ACR_TXDIS) { in __start_tx()
1535 up->acr &= ~UART_ACR_TXDIS; in __start_tx()
1536 serial_icr_write(up, UART_ACR, up->acr); in __start_tx()
1542 * @up: uart 8250 port
1550 void serial8250_em485_start_tx(struct uart_8250_port *up) in serial8250_em485_start_tx() argument
1552 unsigned char mcr = serial8250_in_MCR(up); in serial8250_em485_start_tx()
1554 if (!(up->port.rs485.flags & SER_RS485_RX_DURING_TX)) in serial8250_em485_start_tx()
1555 serial8250_stop_rx(&up->port); in serial8250_em485_start_tx()
1557 if (up->port.rs485.flags & SER_RS485_RTS_ON_SEND) in serial8250_em485_start_tx()
1561 serial8250_out_MCR(up, mcr); in serial8250_em485_start_tx()
1568 struct uart_8250_port *up = up_to_u8250p(port); in start_tx_rs485() local
1569 struct uart_8250_em485 *em485 = up->em485; in start_tx_rs485()
1588 up->rs485_start_tx(up); in start_tx_rs485()
1590 if (up->port.rs485.delay_rts_before_send > 0) { in start_tx_rs485()
1593 up->port.rs485.delay_rts_before_send); in start_tx_rs485()
1620 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_start_tx() local
1621 struct uart_8250_em485 *em485 = up->em485; in serial8250_start_tx()
1629 serial8250_rpm_get_tx(up); in serial8250_start_tx()
1651 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_disable_ms() local
1657 if (up->bugs & UART_BUG_NOMSR) in serial8250_disable_ms()
1660 mctrl_gpio_disable_ms(up->gpios); in serial8250_disable_ms()
1662 up->ier &= ~UART_IER_MSI; in serial8250_disable_ms()
1663 serial_port_out(port, UART_IER, up->ier); in serial8250_disable_ms()
1668 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_enable_ms() local
1674 if (up->bugs & UART_BUG_NOMSR) in serial8250_enable_ms()
1677 mctrl_gpio_enable_ms(up->gpios); in serial8250_enable_ms()
1679 up->ier |= UART_IER_MSI; in serial8250_enable_ms()
1681 serial8250_rpm_get(up); in serial8250_enable_ms()
1682 serial_port_out(port, UART_IER, up->ier); in serial8250_enable_ms()
1683 serial8250_rpm_put(up); in serial8250_enable_ms()
1686 void serial8250_read_char(struct uart_8250_port *up, u16 lsr) in serial8250_read_char() argument
1688 struct uart_port *port = &up->port; in serial8250_read_char()
1692 ch = serial_in(up, UART_RX); in serial8250_read_char()
1705 lsr |= up->lsr_saved_flags; in serial8250_read_char()
1706 up->lsr_saved_flags = 0; in serial8250_read_char()
1754 u16 serial8250_rx_chars(struct uart_8250_port *up, u16 lsr) in serial8250_rx_chars() argument
1756 struct uart_port *port = &up->port; in serial8250_rx_chars()
1760 serial8250_read_char(up, lsr); in serial8250_rx_chars()
1763 lsr = serial_in(up, UART_LSR); in serial8250_rx_chars()
1771 void serial8250_tx_chars(struct uart_8250_port *up) in serial8250_tx_chars() argument
1773 struct uart_port *port = &up->port; in serial8250_tx_chars()
1786 __stop_tx(up); in serial8250_tx_chars()
1790 count = up->tx_loadsz; in serial8250_tx_chars()
1797 serial_out(up, UART_TX, c); in serial8250_tx_chars()
1798 if (up->bugs & UART_BUG_TXRACE) { in serial8250_tx_chars()
1808 serial_in(up, UART_SCR); in serial8250_tx_chars()
1811 if ((up->capabilities & UART_CAP_HFIFO) && in serial8250_tx_chars()
1812 !uart_lsr_tx_empty(serial_in(up, UART_LSR))) in serial8250_tx_chars()
1815 if ((up->capabilities & UART_CAP_MINI) && in serial8250_tx_chars()
1816 !(serial_in(up, UART_LSR) & UART_LSR_THRE)) in serial8250_tx_chars()
1829 !(up->capabilities & UART_CAP_RPM)) in serial8250_tx_chars()
1830 __stop_tx(up); in serial8250_tx_chars()
1835 unsigned int serial8250_modem_status(struct uart_8250_port *up) in serial8250_modem_status() argument
1837 struct uart_port *port = &up->port; in serial8250_modem_status()
1838 unsigned int status = serial_in(up, UART_MSR); in serial8250_modem_status()
1840 status |= up->msr_saved_flags; in serial8250_modem_status()
1841 up->msr_saved_flags = 0; in serial8250_modem_status()
1842 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI && in serial8250_modem_status()
1860 static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir) in handle_rx_dma() argument
1875 if (!up->dma->rx_running) in handle_rx_dma()
1880 serial8250_rx_dma_flush(up); in handle_rx_dma()
1883 return up->dma->rx_dma(up); in handle_rx_dma()
1891 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_handle_irq() local
1902 status = serial_lsr_in(up); in serial8250_handle_irq()
1923 if (!up->dma || handle_rx_dma(up, iir)) in serial8250_handle_irq()
1924 status = serial8250_rx_chars(up, status); in serial8250_handle_irq()
1926 serial8250_modem_status(up); in serial8250_handle_irq()
1927 if ((status & UART_LSR_THRE) && (up->ier & UART_IER_THRI)) { in serial8250_handle_irq()
1928 if (!up->dma || up->dma->tx_err) in serial8250_handle_irq()
1929 serial8250_tx_chars(up); in serial8250_handle_irq()
1930 else if (!up->dma->tx_running) in serial8250_handle_irq()
1931 __stop_tx(up); in serial8250_handle_irq()
1942 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_default_handle_irq() local
1946 serial8250_rpm_get(up); in serial8250_default_handle_irq()
1951 serial8250_rpm_put(up); in serial8250_default_handle_irq()
1959 * has space available. Load it up with tx_loadsz bytes.
1966 /* TX Threshold IRQ triggered so load up FIFO */ in serial8250_tx_threshold_handle_irq()
1968 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_tx_threshold_handle_irq() local
1971 serial8250_tx_chars(up); in serial8250_tx_threshold_handle_irq()
1981 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_tx_empty() local
1985 serial8250_rpm_get(up); in serial8250_tx_empty()
1988 if (!serial8250_tx_dma_running(up) && uart_lsr_tx_empty(serial_lsr_in(up))) in serial8250_tx_empty()
1992 serial8250_rpm_put(up); in serial8250_tx_empty()
1999 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_get_mctrl() local
2003 serial8250_rpm_get(up); in serial8250_do_get_mctrl()
2004 status = serial8250_modem_status(up); in serial8250_do_get_mctrl()
2005 serial8250_rpm_put(up); in serial8250_do_get_mctrl()
2008 if (up->gpios) in serial8250_do_get_mctrl()
2009 return mctrl_gpio_get(up->gpios, &val); in serial8250_do_get_mctrl()
2024 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_set_mctrl() local
2029 mcr |= up->mcr; in serial8250_do_set_mctrl()
2031 serial8250_out_MCR(up, mcr); in serial8250_do_set_mctrl()
2048 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_break_ctl() local
2051 serial8250_rpm_get(up); in serial8250_break_ctl()
2054 up->lcr |= UART_LCR_SBC; in serial8250_break_ctl()
2056 up->lcr &= ~UART_LCR_SBC; in serial8250_break_ctl()
2057 serial_port_out(port, UART_LCR, up->lcr); in serial8250_break_ctl()
2059 serial8250_rpm_put(up); in serial8250_break_ctl()
2062 static void wait_for_lsr(struct uart_8250_port *up, int bits) in wait_for_lsr() argument
2066 /* Wait up to 10ms for the character(s) to be sent. */ in wait_for_lsr()
2068 status = serial_lsr_in(up); in wait_for_lsr()
2082 static void wait_for_xmitr(struct uart_8250_port *up, int bits) in wait_for_xmitr() argument
2086 wait_for_lsr(up, bits); in wait_for_xmitr()
2088 /* Wait up to 1s for flow control if necessary */ in wait_for_xmitr()
2089 if (up->port.flags & UPF_CONS_FLOW) { in wait_for_xmitr()
2091 unsigned int msr = serial_in(up, UART_MSR); in wait_for_xmitr()
2092 up->msr_saved_flags |= msr & MSR_SAVE_FLAGS; in wait_for_xmitr()
2109 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_get_poll_char() local
2113 serial8250_rpm_get(up); in serial8250_get_poll_char()
2124 serial8250_rpm_put(up); in serial8250_get_poll_char()
2133 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_put_poll_char() local
2143 serial8250_rpm_get(up); in serial8250_put_poll_char()
2148 serial8250_clear_IER(up); in serial8250_put_poll_char()
2150 wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); in serial8250_put_poll_char()
2160 wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); in serial8250_put_poll_char()
2162 serial8250_rpm_put(up); in serial8250_put_poll_char()
2169 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_startup() local
2177 if (!up->tx_loadsz) in serial8250_do_startup()
2178 up->tx_loadsz = uart_config[port->type].tx_loadsz; in serial8250_do_startup()
2179 if (!up->capabilities) in serial8250_do_startup()
2180 up->capabilities = uart_config[port->type].flags; in serial8250_do_startup()
2181 up->mcr = 0; in serial8250_do_startup()
2183 if (port->iotype != up->cur_iotype) in serial8250_do_startup()
2186 serial8250_rpm_get(up); in serial8250_do_startup()
2189 * Wake up and initialize UART in serial8250_do_startup()
2194 up->acr = 0; in serial8250_do_startup()
2199 serial_icr_write(up, UART_CSR, 0); /* Reset the UART */ in serial8250_do_startup()
2227 * If this is an RSA port, see if we can kick it up to the in serial8250_do_startup()
2230 enable_rsa(up); in serial8250_do_startup()
2237 serial8250_clear_fifos(up); in serial8250_do_startup()
2265 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial8250_do_startup()
2267 fctr = serial_in(up, UART_FCTR) & ~(UART_FCTR_RX|UART_FCTR_TX); in serial8250_do_startup()
2285 if ((up->tx_loadsz < 2) || (up->tx_loadsz > port->fifosize)) { in serial8250_do_startup()
2291 port->fifosize - up->tx_loadsz); in serial8250_do_startup()
2297 if (port->irq && (up->port.flags & UPF_SHARE_IRQ)) in serial8250_do_startup()
2298 up->port.irqflags |= IRQF_SHARED; in serial8250_do_startup()
2300 retval = up->ops->setup_irq(up); in serial8250_do_startup()
2304 if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) { in serial8250_do_startup()
2322 wait_for_xmitr(up, UART_LSR_THRE); in serial8250_do_startup()
2343 up->port.flags & UPF_BUG_THRE) { in serial8250_do_startup()
2344 up->bugs |= UART_BUG_THRE; in serial8250_do_startup()
2348 up->ops->setup_timer(up); in serial8250_do_startup()
2356 if (up->port.flags & UPF_FOURPORT) { in serial8250_do_startup()
2357 if (!up->port.irq) in serial8250_do_startup()
2358 up->port.mctrl |= TIOCM_OUT1; in serial8250_do_startup()
2364 up->port.mctrl |= TIOCM_OUT2; in serial8250_do_startup()
2379 if (up->port.quirks & UPQ_NO_TXEN_TEST) in serial8250_do_startup()
2392 if (!(up->bugs & UART_BUG_TXEN)) { in serial8250_do_startup()
2393 up->bugs |= UART_BUG_TXEN; in serial8250_do_startup()
2397 up->bugs &= ~UART_BUG_TXEN; in serial8250_do_startup()
2412 up->lsr_saved_flags = 0; in serial8250_do_startup()
2413 up->msr_saved_flags = 0; in serial8250_do_startup()
2418 if (up->dma) { in serial8250_do_startup()
2423 else if (serial8250_request_dma(up)) in serial8250_do_startup()
2427 up->dma = NULL; in serial8250_do_startup()
2436 up->ier = UART_IER_RLSI | UART_IER_RDI; in serial8250_do_startup()
2449 serial8250_rpm_put(up); in serial8250_do_startup()
2463 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_shutdown() local
2466 serial8250_rpm_get(up); in serial8250_do_shutdown()
2473 up->ier = 0; in serial8250_do_shutdown()
2479 if (up->dma) in serial8250_do_shutdown()
2480 serial8250_release_dma(up); in serial8250_do_shutdown()
2498 serial8250_clear_fifos(up); in serial8250_do_shutdown()
2504 disable_rsa(up); in serial8250_do_shutdown()
2512 serial8250_rpm_put(up); in serial8250_do_shutdown()
2514 up->ops->release_irq(up); in serial8250_do_shutdown()
2531 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_get_divisor() local
2537 * up to clk/4 (0x8001) and clk/8 (0x8002) respectively. These in serial8250_do_get_divisor()
2576 if (up->bugs & UART_BUG_QUOT && (quot & 0xff) == 0) in serial8250_do_get_divisor()
2592 static unsigned char serial8250_compute_lcr(struct uart_8250_port *up, in serial8250_compute_lcr() argument
2614 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_set_divisor() local
2617 if (is_omap1510_8250(up)) { in serial8250_do_set_divisor()
2629 if (up->capabilities & UART_NATSEMI) in serial8250_do_set_divisor()
2632 serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB); in serial8250_do_set_divisor()
2634 serial_dl_write(up, quot); in serial8250_do_set_divisor()
2719 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_set_termios() local
2724 if (up->capabilities & UART_CAP_MINI) { in serial8250_do_set_termios()
2730 cval = serial8250_compute_lcr(up, termios->c_cflag); in serial8250_do_set_termios()
2741 serial8250_rpm_get(up); in serial8250_do_set_termios()
2744 up->lcr = cval; /* Save computed LCR */ in serial8250_do_set_termios()
2746 if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) { in serial8250_do_set_termios()
2747 if (baud < 2400 && !up->dma) { in serial8250_do_set_termios()
2748 up->fcr &= ~UART_FCR_TRIGGER_MASK; in serial8250_do_set_termios()
2749 up->fcr |= UART_FCR_TRIGGER_1; in serial8250_do_set_termios()
2758 if (up->capabilities & UART_CAP_AFE) { in serial8250_do_set_termios()
2759 up->mcr &= ~UART_MCR_AFE; in serial8250_do_set_termios()
2761 up->mcr |= UART_MCR_AFE; in serial8250_do_set_termios()
2800 up->ier &= ~UART_IER_MSI; in serial8250_do_set_termios()
2801 if (!(up->bugs & UART_BUG_NOMSR) && in serial8250_do_set_termios()
2802 UART_ENABLE_MS(&up->port, termios->c_cflag)) in serial8250_do_set_termios()
2803 up->ier |= UART_IER_MSI; in serial8250_do_set_termios()
2804 if (up->capabilities & UART_CAP_UUE) in serial8250_do_set_termios()
2805 up->ier |= UART_IER_UUE; in serial8250_do_set_termios()
2806 if (up->capabilities & UART_CAP_RTOIE) in serial8250_do_set_termios()
2807 up->ier |= UART_IER_RTOIE; in serial8250_do_set_termios()
2809 serial_port_out(port, UART_IER, up->ier); in serial8250_do_set_termios()
2811 if (up->capabilities & UART_CAP_EFR) { in serial8250_do_set_termios()
2835 serial_port_out(port, UART_FCR, up->fcr); in serial8250_do_set_termios()
2837 serial_port_out(port, UART_LCR, up->lcr); /* reset DLAB */ in serial8250_do_set_termios()
2840 if (up->fcr & UART_FCR_ENABLE_FIFO) in serial8250_do_set_termios()
2842 serial_port_out(port, UART_FCR, up->fcr); /* set fcr */ in serial8250_do_set_termios()
2846 serial8250_rpm_put(up); in serial8250_do_set_termios()
2923 static int serial8250_request_std_resource(struct uart_8250_port *up) in serial8250_request_std_resource() argument
2925 unsigned int size = serial8250_port_size(up); in serial8250_request_std_resource()
2926 struct uart_port *port = &up->port; in serial8250_request_std_resource()
2964 static void serial8250_release_std_resource(struct uart_8250_port *up) in serial8250_release_std_resource() argument
2966 unsigned int size = serial8250_port_size(up); in serial8250_release_std_resource()
2967 struct uart_port *port = &up->port; in serial8250_release_std_resource()
2996 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_release_port() local
2998 serial8250_release_std_resource(up); in serial8250_release_port()
3003 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_request_port() local
3005 return serial8250_request_std_resource(up); in serial8250_request_port()
3008 static int fcr_get_rxtrig_bytes(struct uart_8250_port *up) in fcr_get_rxtrig_bytes() argument
3010 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in fcr_get_rxtrig_bytes()
3013 bytes = conf_type->rxtrig_bytes[UART_FCR_R_TRIG_BITS(up->fcr)]; in fcr_get_rxtrig_bytes()
3018 static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, unsigned char bytes) in bytes_to_fcr_rxtrig() argument
3020 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in bytes_to_fcr_rxtrig()
3039 struct uart_8250_port *up = up_to_u8250p(uport); in do_get_rxtrig() local
3041 if (!(up->capabilities & UART_CAP_FIFO) || uport->fifosize <= 1) in do_get_rxtrig()
3044 return fcr_get_rxtrig_bytes(up); in do_get_rxtrig()
3075 struct uart_8250_port *up = up_to_u8250p(uport); in do_set_rxtrig() local
3078 if (!(up->capabilities & UART_CAP_FIFO) || uport->fifosize <= 1) in do_set_rxtrig()
3081 rxtrig = bytes_to_fcr_rxtrig(up, bytes); in do_set_rxtrig()
3085 serial8250_clear_fifos(up); in do_set_rxtrig()
3086 up->fcr &= ~UART_FCR_TRIGGER_MASK; in do_set_rxtrig()
3087 up->fcr |= (unsigned char)rxtrig; in do_set_rxtrig()
3088 serial_out(up, UART_FCR, up->fcr); in do_set_rxtrig()
3135 static void register_dev_spec_attr_grp(struct uart_8250_port *up) in register_dev_spec_attr_grp() argument
3137 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in register_dev_spec_attr_grp()
3140 up->port.attr_group = &serial8250_dev_attr_group; in register_dev_spec_attr_grp()
3145 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_config_port() local
3152 ret = serial8250_request_std_resource(up); in serial8250_config_port()
3156 if (port->iotype != up->cur_iotype) in serial8250_config_port()
3160 autoconfig(up); in serial8250_config_port()
3164 up->bugs |= UART_BUG_NOMSR; in serial8250_config_port()
3167 autoconfig_irq(up); in serial8250_config_port()
3170 serial8250_release_std_resource(up); in serial8250_config_port()
3172 register_dev_spec_attr_grp(up); in serial8250_config_port()
3173 up->fcr = uart_config[up->port.type].fcr; in serial8250_config_port()
3223 void serial8250_init_port(struct uart_8250_port *up) in serial8250_init_port() argument
3225 struct uart_port *port = &up->port; in serial8250_init_port()
3233 up->cur_iotype = 0xFF; in serial8250_init_port()
3237 void serial8250_set_defaults(struct uart_8250_port *up) in serial8250_set_defaults() argument
3239 struct uart_port *port = &up->port; in serial8250_set_defaults()
3241 if (up->port.flags & UPF_FIXED_TYPE) { in serial8250_set_defaults()
3242 unsigned int type = up->port.type; in serial8250_set_defaults()
3244 if (!up->port.fifosize) in serial8250_set_defaults()
3245 up->port.fifosize = uart_config[type].fifo_size; in serial8250_set_defaults()
3246 if (!up->tx_loadsz) in serial8250_set_defaults()
3247 up->tx_loadsz = uart_config[type].tx_loadsz; in serial8250_set_defaults()
3248 if (!up->capabilities) in serial8250_set_defaults()
3249 up->capabilities = uart_config[type].flags; in serial8250_set_defaults()
3255 if (up->dma) { in serial8250_set_defaults()
3256 if (!up->dma->tx_dma) in serial8250_set_defaults()
3257 up->dma->tx_dma = serial8250_tx_dma; in serial8250_set_defaults()
3258 if (!up->dma->rx_dma) in serial8250_set_defaults()
3259 up->dma->rx_dma = serial8250_rx_dma; in serial8250_set_defaults()
3268 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_console_putchar() local
3270 wait_for_xmitr(up, UART_LSR_THRE); in serial8250_console_putchar()
3277 static void serial8250_console_restore(struct uart_8250_port *up) in serial8250_console_restore() argument
3279 struct uart_port *port = &up->port; in serial8250_console_restore()
3296 serial_port_out(port, UART_LCR, up->lcr); in serial8250_console_restore()
3297 serial8250_out_MCR(up, up->mcr | UART_MCR_DTR | UART_MCR_RTS); in serial8250_console_restore()
3306 static void serial8250_console_fifo_write(struct uart_8250_port *up, in serial8250_console_fifo_write() argument
3311 unsigned int fifosize = up->tx_loadsz; in serial8250_console_fifo_write()
3315 wait_for_lsr(up, UART_LSR_THRE); in serial8250_console_fifo_write()
3319 serial_out(up, UART_TX, '\r'); in serial8250_console_fifo_write()
3322 serial_out(up, UART_TX, *s++); in serial8250_console_fifo_write()
3336 * Thus, we assume the function is called when device is powered up.
3338 void serial8250_console_write(struct uart_8250_port *up, const char *s, in serial8250_console_write() argument
3341 struct uart_8250_em485 *em485 = up->em485; in serial8250_console_write()
3342 struct uart_port *port = &up->port; in serial8250_console_write()
3358 serial8250_clear_IER(up); in serial8250_console_write()
3361 if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) { in serial8250_console_write()
3362 serial8250_console_restore(up); in serial8250_console_write()
3363 up->canary = 0; in serial8250_console_write()
3368 up->rs485_start_tx(up); in serial8250_console_write()
3372 use_fifo = (up->capabilities & UART_CAP_FIFO) && in serial8250_console_write()
3377 !(up->capabilities & UART_CAP_MINI) && in serial8250_console_write()
3381 up->tx_loadsz > 1 && in serial8250_console_write()
3382 (up->fcr & UART_FCR_ENABLE_FIFO) && in serial8250_console_write()
3390 !(up->port.flags & UPF_CONS_FLOW); in serial8250_console_write()
3393 serial8250_console_fifo_write(up, s, count); in serial8250_console_write()
3401 wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); in serial8250_console_write()
3406 up->rs485_stop_tx(up); in serial8250_console_write()
3418 if (up->msr_saved_flags) in serial8250_console_write()
3419 serial8250_modem_status(up); in serial8250_console_write()