Lines Matching full:up
336 static u32 default_serial_dl_read(struct uart_8250_port *up) in default_serial_dl_read() argument
339 unsigned char dll = serial_in(up, UART_DLL); in default_serial_dl_read()
340 unsigned char dlm = serial_in(up, UART_DLM); in default_serial_dl_read()
346 static void default_serial_dl_write(struct uart_8250_port *up, u32 value) in default_serial_dl_write() argument
348 serial_out(up, UART_DLL, value & 0xff); in default_serial_dl_write()
349 serial_out(up, UART_DLM, value >> 8 & 0xff); in default_serial_dl_write()
430 struct uart_8250_port *up = up_to_u8250p(p); in set_io_from_upio() local
432 up->dl_read = default_serial_dl_read; in set_io_from_upio()
433 up->dl_write = default_serial_dl_write; in set_io_from_upio()
467 up->cur_iotype = p->iotype; in set_io_from_upio()
624 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_em485_config() local
638 return serial8250_em485_init(up); in serial8250_em485_config()
640 serial8250_em485_destroy(up); in serial8250_em485_config()
712 static void serial8250_clear_IER(struct uart_8250_port *up) in serial8250_clear_IER() argument
714 if (up->capabilities & UART_CAP_UUE) in serial8250_clear_IER()
715 serial_out(up, UART_IER, UART_IER_UUE); in serial8250_clear_IER()
717 serial_out(up, UART_IER, 0); in serial8250_clear_IER()
725 static int __enable_rsa(struct uart_8250_port *up) in __enable_rsa() argument
730 mode = serial_in(up, UART_RSA_MSR); in __enable_rsa()
734 serial_out(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); in __enable_rsa()
735 mode = serial_in(up, UART_RSA_MSR); in __enable_rsa()
740 up->port.uartclk = SERIAL_RSA_BAUD_BASE * 16; in __enable_rsa()
745 static void enable_rsa(struct uart_8250_port *up) in enable_rsa() argument
747 if (up->port.type == PORT_RSA) { in enable_rsa()
748 if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) { in enable_rsa()
749 spin_lock_irq(&up->port.lock); in enable_rsa()
750 __enable_rsa(up); in enable_rsa()
751 spin_unlock_irq(&up->port.lock); in enable_rsa()
753 if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) in enable_rsa()
754 serial_out(up, UART_RSA_FRR, 0); in enable_rsa()
764 static void disable_rsa(struct uart_8250_port *up) in disable_rsa() argument
769 if (up->port.type == PORT_RSA && in disable_rsa()
770 up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) { in disable_rsa()
771 spin_lock_irq(&up->port.lock); in disable_rsa()
773 mode = serial_in(up, UART_RSA_MSR); in disable_rsa()
777 serial_out(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); in disable_rsa()
778 mode = serial_in(up, UART_RSA_MSR); in disable_rsa()
783 up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16; in disable_rsa()
784 spin_unlock_irq(&up->port.lock); in disable_rsa()
793 static int size_fifo(struct uart_8250_port *up) in size_fifo() argument
799 old_lcr = serial_in(up, UART_LCR); in size_fifo()
800 serial_out(up, UART_LCR, 0); in size_fifo()
801 old_fcr = serial_in(up, UART_FCR); in size_fifo()
802 old_mcr = serial8250_in_MCR(up); in size_fifo()
803 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in size_fifo()
805 serial8250_out_MCR(up, UART_MCR_LOOP); in size_fifo()
806 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in size_fifo()
807 old_dl = serial_dl_read(up); in size_fifo()
808 serial_dl_write(up, 0x0001); in size_fifo()
809 serial_out(up, UART_LCR, UART_LCR_WLEN8); in size_fifo()
811 serial_out(up, UART_TX, count); in size_fifo()
813 for (count = 0; (serial_in(up, UART_LSR) & UART_LSR_DR) && in size_fifo()
815 serial_in(up, UART_RX); in size_fifo()
816 serial_out(up, UART_FCR, old_fcr); in size_fifo()
817 serial8250_out_MCR(up, old_mcr); in size_fifo()
818 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in size_fifo()
819 serial_dl_write(up, old_dl); in size_fifo()
820 serial_out(up, UART_LCR, old_lcr); in size_fifo()
857 static void autoconfig_has_efr(struct uart_8250_port *up) in autoconfig_has_efr() argument
864 up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP; in autoconfig_has_efr()
870 * Semiconductor clone chips lock up if you try writing to the in autoconfig_has_efr()
883 up->acr = 0; in autoconfig_has_efr()
884 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig_has_efr()
885 serial_out(up, UART_EFR, UART_EFR_ECB); in autoconfig_has_efr()
886 serial_out(up, UART_LCR, 0x00); in autoconfig_has_efr()
887 id1 = serial_icr_read(up, UART_ID1); in autoconfig_has_efr()
888 id2 = serial_icr_read(up, UART_ID2); in autoconfig_has_efr()
889 id3 = serial_icr_read(up, UART_ID3); in autoconfig_has_efr()
890 rev = serial_icr_read(up, UART_REV); in autoconfig_has_efr()
896 up->port.type = PORT_16C950; in autoconfig_has_efr()
904 up->bugs |= UART_BUG_QUOT; in autoconfig_has_efr()
916 id1 = autoconfig_read_divisor_id(up); in autoconfig_has_efr()
921 up->port.type = PORT_16850; in autoconfig_has_efr()
934 if (size_fifo(up) == 64) in autoconfig_has_efr()
935 up->port.type = PORT_16654; in autoconfig_has_efr()
937 up->port.type = PORT_16650V2; in autoconfig_has_efr()
945 static void autoconfig_8250(struct uart_8250_port *up) in autoconfig_8250() argument
949 up->port.type = PORT_8250; in autoconfig_8250()
951 scratch = serial_in(up, UART_SCR); in autoconfig_8250()
952 serial_out(up, UART_SCR, 0xa5); in autoconfig_8250()
953 status1 = serial_in(up, UART_SCR); in autoconfig_8250()
954 serial_out(up, UART_SCR, 0x5a); in autoconfig_8250()
955 status2 = serial_in(up, UART_SCR); in autoconfig_8250()
956 serial_out(up, UART_SCR, scratch); in autoconfig_8250()
959 up->port.type = PORT_16450; in autoconfig_8250()
962 static int broken_efr(struct uart_8250_port *up) in broken_efr() argument
969 if (autoconfig_read_divisor_id(up) == 0x0201 && size_fifo(up) == 16) in broken_efr()
981 static void autoconfig_16550a(struct uart_8250_port *up) in autoconfig_16550a() argument
987 lockdep_assert_held_once(&up->port.lock); in autoconfig_16550a()
989 up->port.type = PORT_16550A; in autoconfig_16550a()
990 up->capabilities |= UART_CAP_FIFO; in autoconfig_16550a()
993 !(up->port.flags & UPF_FULL_PROBE)) in autoconfig_16550a()
1000 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in autoconfig_16550a()
1001 if (serial_in(up, UART_EFR) == 0) { in autoconfig_16550a()
1002 serial_out(up, UART_EFR, 0xA8); in autoconfig_16550a()
1003 if (serial_in(up, UART_EFR) != 0) { in autoconfig_16550a()
1005 up->port.type = PORT_16650; in autoconfig_16550a()
1006 up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP; in autoconfig_16550a()
1008 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1009 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in autoconfig_16550a()
1011 status1 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | in autoconfig_16550a()
1013 serial_out(up, UART_FCR, 0); in autoconfig_16550a()
1014 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1017 up->port.type = PORT_16550A_FSL64; in autoconfig_16550a()
1021 serial_out(up, UART_EFR, 0); in autoconfig_16550a()
1029 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig_16550a()
1030 if (serial_in(up, UART_EFR) == 0 && !broken_efr(up)) { in autoconfig_16550a()
1032 autoconfig_has_efr(up); in autoconfig_16550a()
1043 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1044 status1 = serial8250_in_MCR(up); in autoconfig_16550a()
1045 serial_out(up, UART_LCR, 0xE0); in autoconfig_16550a()
1046 status2 = serial_in(up, 0x02); /* EXCR1 */ in autoconfig_16550a()
1049 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1050 serial8250_out_MCR(up, status1 ^ UART_MCR_LOOP); in autoconfig_16550a()
1051 serial_out(up, UART_LCR, 0xE0); in autoconfig_16550a()
1052 status2 = serial_in(up, 0x02); /* EXCR1 */ in autoconfig_16550a()
1053 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1054 serial8250_out_MCR(up, status1); in autoconfig_16550a()
1059 serial_out(up, UART_LCR, 0xE0); in autoconfig_16550a()
1061 quot = serial_dl_read(up); in autoconfig_16550a()
1064 if (ns16550a_goto_highspeed(up)) in autoconfig_16550a()
1065 serial_dl_write(up, quot); in autoconfig_16550a()
1067 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1069 up->port.uartclk = 921600*16; in autoconfig_16550a()
1070 up->port.type = PORT_NS16550A; in autoconfig_16550a()
1071 up->capabilities |= UART_NATSEMI; in autoconfig_16550a()
1082 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1083 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); in autoconfig_16550a()
1084 status1 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED); in autoconfig_16550a()
1085 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig_16550a()
1087 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in autoconfig_16550a()
1088 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); in autoconfig_16550a()
1089 status2 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED); in autoconfig_16550a()
1090 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig_16550a()
1092 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1098 up->port.type = PORT_16750; in autoconfig_16550a()
1099 up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP; in autoconfig_16550a()
1111 iersave = serial_in(up, UART_IER); in autoconfig_16550a()
1112 serial_out(up, UART_IER, iersave & ~UART_IER_UUE); in autoconfig_16550a()
1113 if (!(serial_in(up, UART_IER) & UART_IER_UUE)) { in autoconfig_16550a()
1118 serial_out(up, UART_IER, iersave | UART_IER_UUE); in autoconfig_16550a()
1119 if (serial_in(up, UART_IER) & UART_IER_UUE) { in autoconfig_16550a()
1125 up->port.type = PORT_XSCALE; in autoconfig_16550a()
1126 up->capabilities |= UART_CAP_UUE | UART_CAP_RTOIE; in autoconfig_16550a()
1136 serial_out(up, UART_IER, iersave); in autoconfig_16550a()
1142 if (up->port.type == PORT_16550A && size_fifo(up) == 64) { in autoconfig_16550a()
1143 up->port.type = PORT_U6_16550A; in autoconfig_16550a()
1144 up->capabilities |= UART_CAP_AFE; in autoconfig_16550a()
1155 static void autoconfig(struct uart_8250_port *up) in autoconfig() argument
1159 struct uart_port *port = &up->port; in autoconfig()
1177 up->capabilities = 0; in autoconfig()
1178 up->bugs = 0; in autoconfig()
1194 scratch = serial_in(up, UART_IER); in autoconfig()
1195 serial_out(up, UART_IER, 0); in autoconfig()
1203 scratch2 = serial_in(up, UART_IER) & UART_IER_ALL_INTR; in autoconfig()
1204 serial_out(up, UART_IER, UART_IER_ALL_INTR); in autoconfig()
1208 scratch3 = serial_in(up, UART_IER) & UART_IER_ALL_INTR; in autoconfig()
1209 serial_out(up, UART_IER, scratch); in autoconfig()
1221 save_mcr = serial8250_in_MCR(up); in autoconfig()
1222 save_lcr = serial_in(up, UART_LCR); in autoconfig()
1234 serial8250_out_MCR(up, UART_MCR_LOOP | UART_MCR_OUT2 | UART_MCR_RTS); in autoconfig()
1235 status1 = serial_in(up, UART_MSR) & UART_MSR_STATUS_BITS; in autoconfig()
1236 serial8250_out_MCR(up, save_mcr); in autoconfig()
1254 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig()
1255 serial_out(up, UART_EFR, 0); in autoconfig()
1256 serial_out(up, UART_LCR, 0); in autoconfig()
1258 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig()
1260 switch (serial_in(up, UART_IIR) & UART_IIR_FIFO_ENABLED) { in autoconfig()
1262 autoconfig_8250(up); in autoconfig()
1268 autoconfig_16550a(up); in autoconfig()
1279 if (port->type == PORT_16550A && up->probe & UART_PROBE_RSA && in autoconfig()
1280 __enable_rsa(up)) in autoconfig()
1284 serial_out(up, UART_LCR, save_lcr); in autoconfig()
1286 port->fifosize = uart_config[up->port.type].fifo_size; in autoconfig()
1287 old_capabilities = up->capabilities; in autoconfig()
1288 up->capabilities = uart_config[port->type].flags; in autoconfig()
1289 up->tx_loadsz = uart_config[port->type].tx_loadsz; in autoconfig()
1299 serial_out(up, UART_RSA_FRR, 0); in autoconfig()
1301 serial8250_out_MCR(up, save_mcr); in autoconfig()
1302 serial8250_clear_fifos(up); in autoconfig()
1303 serial_in(up, UART_RX); in autoconfig()
1304 serial8250_clear_IER(up); in autoconfig()
1313 fintek_8250_probe(up); in autoconfig()
1315 if (up->capabilities != old_capabilities) { in autoconfig()
1317 old_capabilities, up->capabilities); in autoconfig()
1324 static void autoconfig_irq(struct uart_8250_port *up) in autoconfig_irq() argument
1326 struct uart_port *port = &up->port; in autoconfig_irq()
1342 save_mcr = serial8250_in_MCR(up); in autoconfig_irq()
1345 save_ier = serial_in(up, UART_IER); in autoconfig_irq()
1347 serial8250_out_MCR(up, UART_MCR_OUT1 | UART_MCR_OUT2); in autoconfig_irq()
1350 serial8250_out_MCR(up, 0); in autoconfig_irq()
1353 serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS); in autoconfig_irq()
1355 serial8250_out_MCR(up, in autoconfig_irq()
1360 serial_out(up, UART_IER, UART_IER_ALL_INTR); in autoconfig_irq()
1362 serial_in(up, UART_LSR); in autoconfig_irq()
1363 serial_in(up, UART_RX); in autoconfig_irq()
1364 serial_in(up, UART_IIR); in autoconfig_irq()
1365 serial_in(up, UART_MSR); in autoconfig_irq()
1366 serial_out(up, UART_TX, 0xFF); in autoconfig_irq()
1370 serial8250_out_MCR(up, save_mcr); in autoconfig_irq()
1373 serial_out(up, UART_IER, save_ier); in autoconfig_irq()
1384 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_stop_rx() local
1389 serial8250_rpm_get(up); in serial8250_stop_rx()
1391 up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); in serial8250_stop_rx()
1392 up->port.read_status_mask &= ~UART_LSR_DR; in serial8250_stop_rx()
1393 serial_port_out(port, UART_IER, up->ier); in serial8250_stop_rx()
1395 serial8250_rpm_put(up); in serial8250_stop_rx()
1519 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_stop_tx() local
1521 serial8250_rpm_get(up); in serial8250_stop_tx()
1522 __stop_tx(up); in serial8250_stop_tx()
1528 up->acr |= UART_ACR_TXDIS; in serial8250_stop_tx()
1529 serial_icr_write(up, UART_ACR, up->acr); in serial8250_stop_tx()
1531 serial8250_rpm_put(up); in serial8250_stop_tx()
1536 struct uart_8250_port *up = up_to_u8250p(port); in __start_tx() local
1538 if (up->dma && !up->dma->tx_dma(up)) in __start_tx()
1541 if (serial8250_set_THRI(up)) { in __start_tx()
1542 if (up->bugs & UART_BUG_TXEN) { in __start_tx()
1543 u16 lsr = serial_lsr_in(up); in __start_tx()
1546 serial8250_tx_chars(up); in __start_tx()
1553 if (port->type == PORT_16C950 && up->acr & UART_ACR_TXDIS) { in __start_tx()
1554 up->acr &= ~UART_ACR_TXDIS; in __start_tx()
1555 serial_icr_write(up, UART_ACR, up->acr); in __start_tx()
1561 * @up: uart 8250 port
1569 void serial8250_em485_start_tx(struct uart_8250_port *up) in serial8250_em485_start_tx() argument
1571 unsigned char mcr = serial8250_in_MCR(up); in serial8250_em485_start_tx()
1573 if (!(up->port.rs485.flags & SER_RS485_RX_DURING_TX)) in serial8250_em485_start_tx()
1574 serial8250_stop_rx(&up->port); in serial8250_em485_start_tx()
1576 if (up->port.rs485.flags & SER_RS485_RTS_ON_SEND) in serial8250_em485_start_tx()
1580 serial8250_out_MCR(up, mcr); in serial8250_em485_start_tx()
1587 struct uart_8250_port *up = up_to_u8250p(port); in start_tx_rs485() local
1588 struct uart_8250_em485 *em485 = up->em485; in start_tx_rs485()
1607 up->rs485_start_tx(up); in start_tx_rs485()
1609 if (up->port.rs485.delay_rts_before_send > 0) { in start_tx_rs485()
1612 up->port.rs485.delay_rts_before_send); in start_tx_rs485()
1639 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_start_tx() local
1640 struct uart_8250_em485 *em485 = up->em485; in serial8250_start_tx()
1648 serial8250_rpm_get_tx(up); in serial8250_start_tx()
1670 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_disable_ms() local
1676 if (up->bugs & UART_BUG_NOMSR) in serial8250_disable_ms()
1679 mctrl_gpio_disable_ms(up->gpios); in serial8250_disable_ms()
1681 up->ier &= ~UART_IER_MSI; in serial8250_disable_ms()
1682 serial_port_out(port, UART_IER, up->ier); in serial8250_disable_ms()
1687 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_enable_ms() local
1693 if (up->bugs & UART_BUG_NOMSR) in serial8250_enable_ms()
1696 mctrl_gpio_enable_ms(up->gpios); in serial8250_enable_ms()
1698 up->ier |= UART_IER_MSI; in serial8250_enable_ms()
1700 serial8250_rpm_get(up); in serial8250_enable_ms()
1701 serial_port_out(port, UART_IER, up->ier); in serial8250_enable_ms()
1702 serial8250_rpm_put(up); in serial8250_enable_ms()
1705 void serial8250_read_char(struct uart_8250_port *up, u16 lsr) in serial8250_read_char() argument
1707 struct uart_port *port = &up->port; in serial8250_read_char()
1711 ch = serial_in(up, UART_RX); in serial8250_read_char()
1724 lsr |= up->lsr_saved_flags; in serial8250_read_char()
1725 up->lsr_saved_flags = 0; in serial8250_read_char()
1773 u16 serial8250_rx_chars(struct uart_8250_port *up, u16 lsr) in serial8250_rx_chars() argument
1775 struct uart_port *port = &up->port; in serial8250_rx_chars()
1779 serial8250_read_char(up, lsr); in serial8250_rx_chars()
1782 lsr = serial_in(up, UART_LSR); in serial8250_rx_chars()
1790 void serial8250_tx_chars(struct uart_8250_port *up) in serial8250_tx_chars() argument
1792 struct uart_port *port = &up->port; in serial8250_tx_chars()
1805 __stop_tx(up); in serial8250_tx_chars()
1809 count = up->tx_loadsz; in serial8250_tx_chars()
1811 serial_out(up, UART_TX, xmit->buf[xmit->tail]); in serial8250_tx_chars()
1812 if (up->bugs & UART_BUG_TXRACE) { in serial8250_tx_chars()
1822 serial_in(up, UART_SCR); in serial8250_tx_chars()
1827 if ((up->capabilities & UART_CAP_HFIFO) && in serial8250_tx_chars()
1828 !uart_lsr_tx_empty(serial_in(up, UART_LSR))) in serial8250_tx_chars()
1831 if ((up->capabilities & UART_CAP_MINI) && in serial8250_tx_chars()
1832 !(serial_in(up, UART_LSR) & UART_LSR_THRE)) in serial8250_tx_chars()
1844 if (uart_circ_empty(xmit) && !(up->capabilities & UART_CAP_RPM)) in serial8250_tx_chars()
1845 __stop_tx(up); in serial8250_tx_chars()
1850 unsigned int serial8250_modem_status(struct uart_8250_port *up) in serial8250_modem_status() argument
1852 struct uart_port *port = &up->port; in serial8250_modem_status()
1853 unsigned int status = serial_in(up, UART_MSR); in serial8250_modem_status()
1855 status |= up->msr_saved_flags; in serial8250_modem_status()
1856 up->msr_saved_flags = 0; in serial8250_modem_status()
1857 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI && in serial8250_modem_status()
1875 static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir) in handle_rx_dma() argument
1890 if (!up->dma->rx_running) in handle_rx_dma()
1895 serial8250_rx_dma_flush(up); in handle_rx_dma()
1898 return up->dma->rx_dma(up); in handle_rx_dma()
1906 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_handle_irq() local
1917 status = serial_lsr_in(up); in serial8250_handle_irq()
1938 if (!up->dma || handle_rx_dma(up, iir)) in serial8250_handle_irq()
1939 status = serial8250_rx_chars(up, status); in serial8250_handle_irq()
1941 serial8250_modem_status(up); in serial8250_handle_irq()
1942 if ((status & UART_LSR_THRE) && (up->ier & UART_IER_THRI)) { in serial8250_handle_irq()
1943 if (!up->dma || up->dma->tx_err) in serial8250_handle_irq()
1944 serial8250_tx_chars(up); in serial8250_handle_irq()
1945 else if (!up->dma->tx_running) in serial8250_handle_irq()
1946 __stop_tx(up); in serial8250_handle_irq()
1957 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_default_handle_irq() local
1961 serial8250_rpm_get(up); in serial8250_default_handle_irq()
1966 serial8250_rpm_put(up); in serial8250_default_handle_irq()
1974 * has space available. Load it up with tx_loadsz bytes.
1981 /* TX Threshold IRQ triggered so load up FIFO */ in serial8250_tx_threshold_handle_irq()
1983 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_tx_threshold_handle_irq() local
1986 serial8250_tx_chars(up); in serial8250_tx_threshold_handle_irq()
1996 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_tx_empty() local
2000 serial8250_rpm_get(up); in serial8250_tx_empty()
2003 if (!serial8250_tx_dma_running(up) && uart_lsr_tx_empty(serial_lsr_in(up))) in serial8250_tx_empty()
2007 serial8250_rpm_put(up); in serial8250_tx_empty()
2014 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_get_mctrl() local
2018 serial8250_rpm_get(up); in serial8250_do_get_mctrl()
2019 status = serial8250_modem_status(up); in serial8250_do_get_mctrl()
2020 serial8250_rpm_put(up); in serial8250_do_get_mctrl()
2023 if (up->gpios) in serial8250_do_get_mctrl()
2024 return mctrl_gpio_get(up->gpios, &val); in serial8250_do_get_mctrl()
2039 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_set_mctrl() local
2044 mcr |= up->mcr; in serial8250_do_set_mctrl()
2046 serial8250_out_MCR(up, mcr); in serial8250_do_set_mctrl()
2063 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_break_ctl() local
2066 serial8250_rpm_get(up); in serial8250_break_ctl()
2069 up->lcr |= UART_LCR_SBC; in serial8250_break_ctl()
2071 up->lcr &= ~UART_LCR_SBC; in serial8250_break_ctl()
2072 serial_port_out(port, UART_LCR, up->lcr); in serial8250_break_ctl()
2074 serial8250_rpm_put(up); in serial8250_break_ctl()
2077 static void wait_for_lsr(struct uart_8250_port *up, int bits) in wait_for_lsr() argument
2081 /* Wait up to 10ms for the character(s) to be sent. */ in wait_for_lsr()
2083 status = serial_lsr_in(up); in wait_for_lsr()
2097 static void wait_for_xmitr(struct uart_8250_port *up, int bits) in wait_for_xmitr() argument
2101 wait_for_lsr(up, bits); in wait_for_xmitr()
2103 /* Wait up to 1s for flow control if necessary */ in wait_for_xmitr()
2104 if (up->port.flags & UPF_CONS_FLOW) { in wait_for_xmitr()
2106 unsigned int msr = serial_in(up, UART_MSR); in wait_for_xmitr()
2107 up->msr_saved_flags |= msr & MSR_SAVE_FLAGS; in wait_for_xmitr()
2124 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_get_poll_char() local
2128 serial8250_rpm_get(up); in serial8250_get_poll_char()
2139 serial8250_rpm_put(up); in serial8250_get_poll_char()
2148 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_put_poll_char() local
2158 serial8250_rpm_get(up); in serial8250_put_poll_char()
2163 serial8250_clear_IER(up); in serial8250_put_poll_char()
2165 wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); in serial8250_put_poll_char()
2175 wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); in serial8250_put_poll_char()
2177 serial8250_rpm_put(up); in serial8250_put_poll_char()
2184 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_startup() local
2192 if (!up->tx_loadsz) in serial8250_do_startup()
2193 up->tx_loadsz = uart_config[port->type].tx_loadsz; in serial8250_do_startup()
2194 if (!up->capabilities) in serial8250_do_startup()
2195 up->capabilities = uart_config[port->type].flags; in serial8250_do_startup()
2196 up->mcr = 0; in serial8250_do_startup()
2198 if (port->iotype != up->cur_iotype) in serial8250_do_startup()
2201 serial8250_rpm_get(up); in serial8250_do_startup()
2204 * Wake up and initialize UART in serial8250_do_startup()
2209 up->acr = 0; in serial8250_do_startup()
2214 serial_icr_write(up, UART_CSR, 0); /* Reset the UART */ in serial8250_do_startup()
2251 * If this is an RSA port, see if we can kick it up to the in serial8250_do_startup()
2254 enable_rsa(up); in serial8250_do_startup()
2261 serial8250_clear_fifos(up); in serial8250_do_startup()
2289 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial8250_do_startup()
2291 fctr = serial_in(up, UART_FCTR) & ~(UART_FCTR_RX|UART_FCTR_TX); in serial8250_do_startup()
2309 if ((up->tx_loadsz < 2) || (up->tx_loadsz > port->fifosize)) { in serial8250_do_startup()
2315 port->fifosize - up->tx_loadsz); in serial8250_do_startup()
2321 if (port->irq && (up->port.flags & UPF_SHARE_IRQ)) in serial8250_do_startup()
2322 up->port.irqflags |= IRQF_SHARED; in serial8250_do_startup()
2324 retval = up->ops->setup_irq(up); in serial8250_do_startup()
2328 if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) { in serial8250_do_startup()
2346 wait_for_xmitr(up, UART_LSR_THRE); in serial8250_do_startup()
2367 up->port.flags & UPF_BUG_THRE) { in serial8250_do_startup()
2368 up->bugs |= UART_BUG_THRE; in serial8250_do_startup()
2372 up->ops->setup_timer(up); in serial8250_do_startup()
2380 if (up->port.flags & UPF_FOURPORT) { in serial8250_do_startup()
2381 if (!up->port.irq) in serial8250_do_startup()
2382 up->port.mctrl |= TIOCM_OUT1; in serial8250_do_startup()
2388 up->port.mctrl |= TIOCM_OUT2; in serial8250_do_startup()
2403 if (up->port.quirks & UPQ_NO_TXEN_TEST) in serial8250_do_startup()
2416 if (!(up->bugs & UART_BUG_TXEN)) { in serial8250_do_startup()
2417 up->bugs |= UART_BUG_TXEN; in serial8250_do_startup()
2421 up->bugs &= ~UART_BUG_TXEN; in serial8250_do_startup()
2436 up->lsr_saved_flags = 0; in serial8250_do_startup()
2437 up->msr_saved_flags = 0; in serial8250_do_startup()
2442 if (up->dma) { in serial8250_do_startup()
2447 else if (serial8250_request_dma(up)) in serial8250_do_startup()
2451 up->dma = NULL; in serial8250_do_startup()
2460 up->ier = UART_IER_RLSI | UART_IER_RDI; in serial8250_do_startup()
2473 serial8250_rpm_put(up); in serial8250_do_startup()
2487 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_shutdown() local
2490 serial8250_rpm_get(up); in serial8250_do_shutdown()
2497 up->ier = 0; in serial8250_do_shutdown()
2503 if (up->dma) in serial8250_do_shutdown()
2504 serial8250_release_dma(up); in serial8250_do_shutdown()
2522 serial8250_clear_fifos(up); in serial8250_do_shutdown()
2528 disable_rsa(up); in serial8250_do_shutdown()
2536 serial8250_rpm_put(up); in serial8250_do_shutdown()
2538 up->ops->release_irq(up); in serial8250_do_shutdown()
2551 static unsigned int npcm_get_divisor(struct uart_8250_port *up, in npcm_get_divisor() argument
2554 struct uart_port *port = &up->port; in npcm_get_divisor()
2564 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_get_divisor() local
2570 * up to clk/4 (0x8001) and clk/8 (0x8002) respectively. These in serial8250_do_get_divisor()
2603 else if (up->port.type == PORT_NPCM) in serial8250_do_get_divisor()
2604 quot = npcm_get_divisor(up, baud); in serial8250_do_get_divisor()
2611 if (up->bugs & UART_BUG_QUOT && (quot & 0xff) == 0) in serial8250_do_get_divisor()
2627 static unsigned char serial8250_compute_lcr(struct uart_8250_port *up, in serial8250_compute_lcr() argument
2649 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_set_divisor() local
2652 if (is_omap1510_8250(up)) { in serial8250_do_set_divisor()
2664 if (up->capabilities & UART_NATSEMI) in serial8250_do_set_divisor()
2667 serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB); in serial8250_do_set_divisor()
2669 serial_dl_write(up, quot); in serial8250_do_set_divisor()
2719 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_update_uartclk() local
2750 serial8250_rpm_get(up); in serial8250_update_uartclk()
2756 serial_port_out(port, UART_LCR, up->lcr); in serial8250_update_uartclk()
2759 serial8250_rpm_put(up); in serial8250_update_uartclk()
2772 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_set_termios() local
2777 if (up->capabilities & UART_CAP_MINI) { in serial8250_do_set_termios()
2783 cval = serial8250_compute_lcr(up, termios->c_cflag); in serial8250_do_set_termios()
2794 serial8250_rpm_get(up); in serial8250_do_set_termios()
2797 up->lcr = cval; /* Save computed LCR */ in serial8250_do_set_termios()
2799 if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) { in serial8250_do_set_termios()
2800 if (baud < 2400 && !up->dma) { in serial8250_do_set_termios()
2801 up->fcr &= ~UART_FCR_TRIGGER_MASK; in serial8250_do_set_termios()
2802 up->fcr |= UART_FCR_TRIGGER_1; in serial8250_do_set_termios()
2811 if (up->capabilities & UART_CAP_AFE) { in serial8250_do_set_termios()
2812 up->mcr &= ~UART_MCR_AFE; in serial8250_do_set_termios()
2814 up->mcr |= UART_MCR_AFE; in serial8250_do_set_termios()
2853 up->ier &= ~UART_IER_MSI; in serial8250_do_set_termios()
2854 if (!(up->bugs & UART_BUG_NOMSR) && in serial8250_do_set_termios()
2855 UART_ENABLE_MS(&up->port, termios->c_cflag)) in serial8250_do_set_termios()
2856 up->ier |= UART_IER_MSI; in serial8250_do_set_termios()
2857 if (up->capabilities & UART_CAP_UUE) in serial8250_do_set_termios()
2858 up->ier |= UART_IER_UUE; in serial8250_do_set_termios()
2859 if (up->capabilities & UART_CAP_RTOIE) in serial8250_do_set_termios()
2860 up->ier |= UART_IER_RTOIE; in serial8250_do_set_termios()
2862 serial_port_out(port, UART_IER, up->ier); in serial8250_do_set_termios()
2864 if (up->capabilities & UART_CAP_EFR) { in serial8250_do_set_termios()
2888 serial_port_out(port, UART_FCR, up->fcr); in serial8250_do_set_termios()
2890 serial_port_out(port, UART_LCR, up->lcr); /* reset DLAB */ in serial8250_do_set_termios()
2893 if (up->fcr & UART_FCR_ENABLE_FIFO) in serial8250_do_set_termios()
2895 serial_port_out(port, UART_FCR, up->fcr); /* set fcr */ in serial8250_do_set_termios()
2899 serial8250_rpm_put(up); in serial8250_do_set_termios()
2976 static int serial8250_request_std_resource(struct uart_8250_port *up) in serial8250_request_std_resource() argument
2978 unsigned int size = serial8250_port_size(up); in serial8250_request_std_resource()
2979 struct uart_port *port = &up->port; in serial8250_request_std_resource()
3017 static void serial8250_release_std_resource(struct uart_8250_port *up) in serial8250_release_std_resource() argument
3019 unsigned int size = serial8250_port_size(up); in serial8250_release_std_resource()
3020 struct uart_port *port = &up->port; in serial8250_release_std_resource()
3049 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_release_port() local
3051 serial8250_release_std_resource(up); in serial8250_release_port()
3056 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_request_port() local
3058 return serial8250_request_std_resource(up); in serial8250_request_port()
3061 static int fcr_get_rxtrig_bytes(struct uart_8250_port *up) in fcr_get_rxtrig_bytes() argument
3063 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in fcr_get_rxtrig_bytes()
3066 bytes = conf_type->rxtrig_bytes[UART_FCR_R_TRIG_BITS(up->fcr)]; in fcr_get_rxtrig_bytes()
3071 static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, unsigned char bytes) in bytes_to_fcr_rxtrig() argument
3073 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in bytes_to_fcr_rxtrig()
3092 struct uart_8250_port *up = up_to_u8250p(uport); in do_get_rxtrig() local
3094 if (!(up->capabilities & UART_CAP_FIFO) || uport->fifosize <= 1) in do_get_rxtrig()
3097 return fcr_get_rxtrig_bytes(up); in do_get_rxtrig()
3128 struct uart_8250_port *up = up_to_u8250p(uport); in do_set_rxtrig() local
3131 if (!(up->capabilities & UART_CAP_FIFO) || uport->fifosize <= 1) in do_set_rxtrig()
3134 rxtrig = bytes_to_fcr_rxtrig(up, bytes); in do_set_rxtrig()
3138 serial8250_clear_fifos(up); in do_set_rxtrig()
3139 up->fcr &= ~UART_FCR_TRIGGER_MASK; in do_set_rxtrig()
3140 up->fcr |= (unsigned char)rxtrig; in do_set_rxtrig()
3141 serial_out(up, UART_FCR, up->fcr); in do_set_rxtrig()
3188 static void register_dev_spec_attr_grp(struct uart_8250_port *up) in register_dev_spec_attr_grp() argument
3190 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in register_dev_spec_attr_grp()
3193 up->port.attr_group = &serial8250_dev_attr_group; in register_dev_spec_attr_grp()
3198 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_config_port() local
3205 ret = serial8250_request_std_resource(up); in serial8250_config_port()
3209 if (port->iotype != up->cur_iotype) in serial8250_config_port()
3213 autoconfig(up); in serial8250_config_port()
3217 up->bugs |= UART_BUG_NOMSR; in serial8250_config_port()
3220 autoconfig_irq(up); in serial8250_config_port()
3223 serial8250_release_std_resource(up); in serial8250_config_port()
3225 register_dev_spec_attr_grp(up); in serial8250_config_port()
3226 up->fcr = uart_config[up->port.type].fcr; in serial8250_config_port()
3276 void serial8250_init_port(struct uart_8250_port *up) in serial8250_init_port() argument
3278 struct uart_port *port = &up->port; in serial8250_init_port()
3286 up->cur_iotype = 0xFF; in serial8250_init_port()
3290 void serial8250_set_defaults(struct uart_8250_port *up) in serial8250_set_defaults() argument
3292 struct uart_port *port = &up->port; in serial8250_set_defaults()
3294 if (up->port.flags & UPF_FIXED_TYPE) { in serial8250_set_defaults()
3295 unsigned int type = up->port.type; in serial8250_set_defaults()
3297 if (!up->port.fifosize) in serial8250_set_defaults()
3298 up->port.fifosize = uart_config[type].fifo_size; in serial8250_set_defaults()
3299 if (!up->tx_loadsz) in serial8250_set_defaults()
3300 up->tx_loadsz = uart_config[type].tx_loadsz; in serial8250_set_defaults()
3301 if (!up->capabilities) in serial8250_set_defaults()
3302 up->capabilities = uart_config[type].flags; in serial8250_set_defaults()
3308 if (up->dma) { in serial8250_set_defaults()
3309 if (!up->dma->tx_dma) in serial8250_set_defaults()
3310 up->dma->tx_dma = serial8250_tx_dma; in serial8250_set_defaults()
3311 if (!up->dma->rx_dma) in serial8250_set_defaults()
3312 up->dma->rx_dma = serial8250_rx_dma; in serial8250_set_defaults()
3321 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_console_putchar() local
3323 wait_for_xmitr(up, UART_LSR_THRE); in serial8250_console_putchar()
3330 static void serial8250_console_restore(struct uart_8250_port *up) in serial8250_console_restore() argument
3332 struct uart_port *port = &up->port; in serial8250_console_restore()
3349 serial_port_out(port, UART_LCR, up->lcr); in serial8250_console_restore()
3350 serial8250_out_MCR(up, up->mcr | UART_MCR_DTR | UART_MCR_RTS); in serial8250_console_restore()
3359 static void serial8250_console_fifo_write(struct uart_8250_port *up, in serial8250_console_fifo_write() argument
3364 unsigned int fifosize = up->tx_loadsz; in serial8250_console_fifo_write()
3368 wait_for_lsr(up, UART_LSR_THRE); in serial8250_console_fifo_write()
3372 serial_out(up, UART_TX, '\r'); in serial8250_console_fifo_write()
3375 serial_out(up, UART_TX, *s++); in serial8250_console_fifo_write()
3389 * Thus, we assume the function is called when device is powered up.
3391 void serial8250_console_write(struct uart_8250_port *up, const char *s, in serial8250_console_write() argument
3394 struct uart_8250_em485 *em485 = up->em485; in serial8250_console_write()
3395 struct uart_port *port = &up->port; in serial8250_console_write()
3411 serial8250_clear_IER(up); in serial8250_console_write()
3414 if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) { in serial8250_console_write()
3415 serial8250_console_restore(up); in serial8250_console_write()
3416 up->canary = 0; in serial8250_console_write()
3421 up->rs485_start_tx(up); in serial8250_console_write()
3425 use_fifo = (up->capabilities & UART_CAP_FIFO) && in serial8250_console_write()
3430 !(up->capabilities & UART_CAP_MINI) && in serial8250_console_write()
3434 up->tx_loadsz > 1 && in serial8250_console_write()
3435 (up->fcr & UART_FCR_ENABLE_FIFO) && in serial8250_console_write()
3443 !(up->port.flags & UPF_CONS_FLOW); in serial8250_console_write()
3446 serial8250_console_fifo_write(up, s, count); in serial8250_console_write()
3454 wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); in serial8250_console_write()
3459 up->rs485_stop_tx(up); in serial8250_console_write()
3471 if (up->msr_saved_flags) in serial8250_console_write()
3472 serial8250_modem_status(up); in serial8250_console_write()