Lines Matching refs:up
279 static int default_serial_dl_read(struct uart_8250_port *up) in default_serial_dl_read() argument
281 return serial_in(up, UART_DLL) | serial_in(up, UART_DLM) << 8; in default_serial_dl_read()
285 static void default_serial_dl_write(struct uart_8250_port *up, int value) in default_serial_dl_write() argument
287 serial_out(up, UART_DLL, value & 0xff); in default_serial_dl_write()
288 serial_out(up, UART_DLM, value >> 8 & 0xff); in default_serial_dl_write()
337 static int au_serial_dl_read(struct uart_8250_port *up) in au_serial_dl_read() argument
339 return __raw_readl(up->port.membase + 0x28); in au_serial_dl_read()
342 static void au_serial_dl_write(struct uart_8250_port *up, int value) in au_serial_dl_write() argument
344 __raw_writel(value, up->port.membase + 0x28); in au_serial_dl_write()
428 struct uart_8250_port *up = up_to_u8250p(p); in set_io_from_upio() local
430 up->dl_read = default_serial_dl_read; in set_io_from_upio()
431 up->dl_write = default_serial_dl_write; in set_io_from_upio()
463 up->dl_read = au_serial_dl_read; in set_io_from_upio()
464 up->dl_write = au_serial_dl_write; in set_io_from_upio()
474 up->cur_iotype = p->iotype; in set_io_from_upio()
498 static void serial_icr_write(struct uart_8250_port *up, int offset, int value) in serial_icr_write() argument
500 serial_out(up, UART_SCR, offset); in serial_icr_write()
501 serial_out(up, UART_ICR, value); in serial_icr_write()
504 static unsigned int serial_icr_read(struct uart_8250_port *up, int offset) in serial_icr_read() argument
508 serial_icr_write(up, UART_ACR, up->acr | UART_ACR_ICRRD); in serial_icr_read()
509 serial_out(up, UART_SCR, offset); in serial_icr_read()
510 value = serial_in(up, UART_ICR); in serial_icr_read()
511 serial_icr_write(up, UART_ACR, up->acr); in serial_icr_read()
712 static int __enable_rsa(struct uart_8250_port *up) in __enable_rsa() argument
717 mode = serial_in(up, UART_RSA_MSR); in __enable_rsa()
721 serial_out(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); in __enable_rsa()
722 mode = serial_in(up, UART_RSA_MSR); in __enable_rsa()
727 up->port.uartclk = SERIAL_RSA_BAUD_BASE * 16; in __enable_rsa()
732 static void enable_rsa(struct uart_8250_port *up) in enable_rsa() argument
734 if (up->port.type == PORT_RSA) { in enable_rsa()
735 if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) { in enable_rsa()
736 spin_lock_irq(&up->port.lock); in enable_rsa()
737 __enable_rsa(up); in enable_rsa()
738 spin_unlock_irq(&up->port.lock); in enable_rsa()
740 if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) in enable_rsa()
741 serial_out(up, UART_RSA_FRR, 0); in enable_rsa()
751 static void disable_rsa(struct uart_8250_port *up) in disable_rsa() argument
756 if (up->port.type == PORT_RSA && in disable_rsa()
757 up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) { in disable_rsa()
758 spin_lock_irq(&up->port.lock); in disable_rsa()
760 mode = serial_in(up, UART_RSA_MSR); in disable_rsa()
764 serial_out(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); in disable_rsa()
765 mode = serial_in(up, UART_RSA_MSR); in disable_rsa()
770 up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16; in disable_rsa()
771 spin_unlock_irq(&up->port.lock); in disable_rsa()
780 static int size_fifo(struct uart_8250_port *up) in size_fifo() argument
786 old_lcr = serial_in(up, UART_LCR); in size_fifo()
787 serial_out(up, UART_LCR, 0); in size_fifo()
788 old_fcr = serial_in(up, UART_FCR); in size_fifo()
789 old_mcr = serial8250_in_MCR(up); in size_fifo()
790 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in size_fifo()
792 serial8250_out_MCR(up, UART_MCR_LOOP); in size_fifo()
793 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in size_fifo()
794 old_dl = serial_dl_read(up); in size_fifo()
795 serial_dl_write(up, 0x0001); in size_fifo()
796 serial_out(up, UART_LCR, 0x03); in size_fifo()
798 serial_out(up, UART_TX, count); in size_fifo()
800 for (count = 0; (serial_in(up, UART_LSR) & UART_LSR_DR) && in size_fifo()
802 serial_in(up, UART_RX); in size_fifo()
803 serial_out(up, UART_FCR, old_fcr); in size_fifo()
804 serial8250_out_MCR(up, old_mcr); in size_fifo()
805 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in size_fifo()
806 serial_dl_write(up, old_dl); in size_fifo()
807 serial_out(up, UART_LCR, old_lcr); in size_fifo()
844 static void autoconfig_has_efr(struct uart_8250_port *up) in autoconfig_has_efr() argument
851 up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP; in autoconfig_has_efr()
870 up->acr = 0; in autoconfig_has_efr()
871 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig_has_efr()
872 serial_out(up, UART_EFR, UART_EFR_ECB); in autoconfig_has_efr()
873 serial_out(up, UART_LCR, 0x00); in autoconfig_has_efr()
874 id1 = serial_icr_read(up, UART_ID1); in autoconfig_has_efr()
875 id2 = serial_icr_read(up, UART_ID2); in autoconfig_has_efr()
876 id3 = serial_icr_read(up, UART_ID3); in autoconfig_has_efr()
877 rev = serial_icr_read(up, UART_REV); in autoconfig_has_efr()
883 up->port.type = PORT_16C950; in autoconfig_has_efr()
891 up->bugs |= UART_BUG_QUOT; in autoconfig_has_efr()
903 id1 = autoconfig_read_divisor_id(up); in autoconfig_has_efr()
908 up->port.type = PORT_16850; in autoconfig_has_efr()
921 if (size_fifo(up) == 64) in autoconfig_has_efr()
922 up->port.type = PORT_16654; in autoconfig_has_efr()
924 up->port.type = PORT_16650V2; in autoconfig_has_efr()
932 static void autoconfig_8250(struct uart_8250_port *up) in autoconfig_8250() argument
936 up->port.type = PORT_8250; in autoconfig_8250()
938 scratch = serial_in(up, UART_SCR); in autoconfig_8250()
939 serial_out(up, UART_SCR, 0xa5); in autoconfig_8250()
940 status1 = serial_in(up, UART_SCR); in autoconfig_8250()
941 serial_out(up, UART_SCR, 0x5a); in autoconfig_8250()
942 status2 = serial_in(up, UART_SCR); in autoconfig_8250()
943 serial_out(up, UART_SCR, scratch); in autoconfig_8250()
946 up->port.type = PORT_16450; in autoconfig_8250()
949 static int broken_efr(struct uart_8250_port *up) in broken_efr() argument
956 if (autoconfig_read_divisor_id(up) == 0x0201 && size_fifo(up) == 16) in broken_efr()
968 static void autoconfig_16550a(struct uart_8250_port *up) in autoconfig_16550a() argument
973 up->port.type = PORT_16550A; in autoconfig_16550a()
974 up->capabilities |= UART_CAP_FIFO; in autoconfig_16550a()
984 if (up->port.flags & UPF_EXAR_EFR) { in autoconfig_16550a()
985 status1 = serial_in(up, UART_EXAR_DVID); in autoconfig_16550a()
988 up->port.type = PORT_XR17V35X; in autoconfig_16550a()
989 up->capabilities |= UART_CAP_AFE | UART_CAP_EFR | in autoconfig_16550a()
1001 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in autoconfig_16550a()
1002 if (serial_in(up, UART_EFR) == 0) { in autoconfig_16550a()
1003 serial_out(up, UART_EFR, 0xA8); in autoconfig_16550a()
1004 if (serial_in(up, UART_EFR) != 0) { in autoconfig_16550a()
1006 up->port.type = PORT_16650; in autoconfig_16550a()
1007 up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP; in autoconfig_16550a()
1009 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1010 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | in autoconfig_16550a()
1012 status1 = serial_in(up, UART_IIR) >> 5; 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) >> 5; in autoconfig_16550a()
1085 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig_16550a()
1086 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in autoconfig_16550a()
1087 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); in autoconfig_16550a()
1088 status2 = serial_in(up, UART_IIR) >> 5; in autoconfig_16550a()
1089 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig_16550a()
1090 serial_out(up, UART_LCR, 0); in autoconfig_16550a()
1095 up->port.type = PORT_16750; in autoconfig_16550a()
1096 up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP; in autoconfig_16550a()
1108 iersave = serial_in(up, UART_IER); in autoconfig_16550a()
1109 serial_out(up, UART_IER, iersave & ~UART_IER_UUE); in autoconfig_16550a()
1110 if (!(serial_in(up, UART_IER) & UART_IER_UUE)) { in autoconfig_16550a()
1115 serial_out(up, UART_IER, iersave | UART_IER_UUE); in autoconfig_16550a()
1116 if (serial_in(up, UART_IER) & UART_IER_UUE) { in autoconfig_16550a()
1122 up->port.type = PORT_XSCALE; in autoconfig_16550a()
1123 up->capabilities |= UART_CAP_UUE | UART_CAP_RTOIE; in autoconfig_16550a()
1133 serial_out(up, UART_IER, iersave); in autoconfig_16550a()
1138 if (up->port.flags & UPF_EXAR_EFR) { in autoconfig_16550a()
1140 up->port.type = PORT_XR17D15X; in autoconfig_16550a()
1141 up->capabilities |= UART_CAP_AFE | UART_CAP_EFR | in autoconfig_16550a()
1151 if (up->port.type == PORT_16550A && size_fifo(up) == 64) { in autoconfig_16550a()
1152 up->port.type = PORT_U6_16550A; in autoconfig_16550a()
1153 up->capabilities |= UART_CAP_AFE; in autoconfig_16550a()
1164 static void autoconfig(struct uart_8250_port *up) in autoconfig() argument
1168 struct uart_port *port = &up->port; in autoconfig()
1184 up->capabilities = 0; in autoconfig()
1185 up->bugs = 0; in autoconfig()
1201 scratch = serial_in(up, UART_IER); in autoconfig()
1202 serial_out(up, UART_IER, 0); in autoconfig()
1210 scratch2 = serial_in(up, UART_IER) & 0x0f; in autoconfig()
1211 serial_out(up, UART_IER, 0x0F); in autoconfig()
1215 scratch3 = serial_in(up, UART_IER) & 0x0f; in autoconfig()
1216 serial_out(up, UART_IER, scratch); in autoconfig()
1228 save_mcr = serial8250_in_MCR(up); in autoconfig()
1229 save_lcr = serial_in(up, UART_LCR); in autoconfig()
1241 serial8250_out_MCR(up, UART_MCR_LOOP | 0x0A); in autoconfig()
1242 status1 = serial_in(up, UART_MSR) & 0xF0; in autoconfig()
1243 serial8250_out_MCR(up, save_mcr); in autoconfig()
1261 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in autoconfig()
1262 serial_out(up, UART_EFR, 0); in autoconfig()
1263 serial_out(up, UART_LCR, 0); in autoconfig()
1265 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); in autoconfig()
1266 scratch = serial_in(up, UART_IIR) >> 6; in autoconfig()
1270 autoconfig_8250(up); in autoconfig()
1279 autoconfig_16550a(up); in autoconfig()
1287 if (port->type == PORT_16550A && up->probe & UART_PROBE_RSA && in autoconfig()
1288 __enable_rsa(up)) in autoconfig()
1292 serial_out(up, UART_LCR, save_lcr); in autoconfig()
1294 port->fifosize = uart_config[up->port.type].fifo_size; in autoconfig()
1295 old_capabilities = up->capabilities; in autoconfig()
1296 up->capabilities = uart_config[port->type].flags; in autoconfig()
1297 up->tx_loadsz = uart_config[port->type].tx_loadsz; in autoconfig()
1307 serial_out(up, UART_RSA_FRR, 0); in autoconfig()
1309 serial8250_out_MCR(up, save_mcr); in autoconfig()
1310 serial8250_clear_fifos(up); in autoconfig()
1311 serial_in(up, UART_RX); in autoconfig()
1312 if (up->capabilities & UART_CAP_UUE) in autoconfig()
1313 serial_out(up, UART_IER, UART_IER_UUE); in autoconfig()
1315 serial_out(up, UART_IER, 0); in autoconfig()
1324 fintek_8250_probe(up); in autoconfig()
1326 if (up->capabilities != old_capabilities) { in autoconfig()
1329 up->capabilities); in autoconfig()
1336 static void autoconfig_irq(struct uart_8250_port *up) in autoconfig_irq() argument
1338 struct uart_port *port = &up->port; in autoconfig_irq()
1357 save_mcr = serial8250_in_MCR(up); in autoconfig_irq()
1358 save_ier = serial_in(up, UART_IER); in autoconfig_irq()
1359 serial8250_out_MCR(up, UART_MCR_OUT1 | UART_MCR_OUT2); in autoconfig_irq()
1362 serial8250_out_MCR(up, 0); in autoconfig_irq()
1365 serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS); in autoconfig_irq()
1367 serial8250_out_MCR(up, in autoconfig_irq()
1370 serial_out(up, UART_IER, 0x0f); /* enable all intrs */ in autoconfig_irq()
1371 serial_in(up, UART_LSR); in autoconfig_irq()
1372 serial_in(up, UART_RX); in autoconfig_irq()
1373 serial_in(up, UART_IIR); in autoconfig_irq()
1374 serial_in(up, UART_MSR); in autoconfig_irq()
1375 serial_out(up, UART_TX, 0xFF); in autoconfig_irq()
1379 serial8250_out_MCR(up, save_mcr); in autoconfig_irq()
1380 serial_out(up, UART_IER, save_ier); in autoconfig_irq()
1393 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_stop_rx() local
1395 serial8250_rpm_get(up); in serial8250_stop_rx()
1397 up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); in serial8250_stop_rx()
1398 up->port.read_status_mask &= ~UART_LSR_DR; in serial8250_stop_rx()
1399 serial_port_out(port, UART_IER, up->ier); in serial8250_stop_rx()
1401 serial8250_rpm_put(up); in serial8250_stop_rx()
1489 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_stop_tx() local
1491 serial8250_rpm_get(up); in serial8250_stop_tx()
1492 __stop_tx(up); in serial8250_stop_tx()
1498 up->acr |= UART_ACR_TXDIS; in serial8250_stop_tx()
1499 serial_icr_write(up, UART_ACR, up->acr); in serial8250_stop_tx()
1501 serial8250_rpm_put(up); in serial8250_stop_tx()
1506 struct uart_8250_port *up = up_to_u8250p(port); in __start_tx() local
1508 if (up->dma && !up->dma->tx_dma(up)) in __start_tx()
1511 if (!(up->ier & UART_IER_THRI)) { in __start_tx()
1512 up->ier |= UART_IER_THRI; in __start_tx()
1513 serial_port_out(port, UART_IER, up->ier); in __start_tx()
1515 if (up->bugs & UART_BUG_TXEN) { in __start_tx()
1518 lsr = serial_in(up, UART_LSR); in __start_tx()
1519 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; in __start_tx()
1521 serial8250_tx_chars(up); in __start_tx()
1528 if (port->type == PORT_16C950 && up->acr & UART_ACR_TXDIS) { in __start_tx()
1529 up->acr &= ~UART_ACR_TXDIS; in __start_tx()
1530 serial_icr_write(up, UART_ACR, up->acr); in __start_tx()
1536 struct uart_8250_port *up = up_to_u8250p(port); in start_tx_rs485() local
1537 struct uart_8250_em485 *em485 = up->em485; in start_tx_rs485()
1540 if (!(up->port.rs485.flags & SER_RS485_RX_DURING_TX)) in start_tx_rs485()
1541 serial8250_stop_rx(&up->port); in start_tx_rs485()
1546 mcr = serial8250_in_MCR(up); in start_tx_rs485()
1547 if (!!(up->port.rs485.flags & SER_RS485_RTS_ON_SEND) != in start_tx_rs485()
1549 if (up->port.rs485.flags & SER_RS485_RTS_ON_SEND) in start_tx_rs485()
1553 serial8250_out_MCR(up, mcr); in start_tx_rs485()
1555 if (up->port.rs485.delay_rts_before_send > 0) { in start_tx_rs485()
1558 up->port.rs485.delay_rts_before_send * HZ / 1000); in start_tx_rs485()
1583 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_start_tx() local
1584 struct uart_8250_em485 *em485 = up->em485; in serial8250_start_tx()
1586 serial8250_rpm_get_tx(up); in serial8250_start_tx()
1610 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_disable_ms() local
1613 if (up->bugs & UART_BUG_NOMSR) in serial8250_disable_ms()
1616 up->ier &= ~UART_IER_MSI; in serial8250_disable_ms()
1617 serial_port_out(port, UART_IER, up->ier); in serial8250_disable_ms()
1622 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_enable_ms() local
1625 if (up->bugs & UART_BUG_NOMSR) in serial8250_enable_ms()
1628 up->ier |= UART_IER_MSI; in serial8250_enable_ms()
1630 serial8250_rpm_get(up); in serial8250_enable_ms()
1631 serial_port_out(port, UART_IER, up->ier); in serial8250_enable_ms()
1632 serial8250_rpm_put(up); in serial8250_enable_ms()
1635 static void serial8250_read_char(struct uart_8250_port *up, unsigned char lsr) in serial8250_read_char() argument
1637 struct uart_port *port = &up->port; in serial8250_read_char()
1642 ch = serial_in(up, UART_RX); in serial8250_read_char()
1655 lsr |= up->lsr_saved_flags; in serial8250_read_char()
1656 up->lsr_saved_flags = 0; in serial8250_read_char()
1701 unsigned char serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) in serial8250_rx_chars() argument
1703 struct uart_port *port = &up->port; in serial8250_rx_chars()
1707 serial8250_read_char(up, lsr); in serial8250_rx_chars()
1710 lsr = serial_in(up, UART_LSR); in serial8250_rx_chars()
1718 void serial8250_tx_chars(struct uart_8250_port *up) in serial8250_tx_chars() argument
1720 struct uart_port *port = &up->port; in serial8250_tx_chars()
1725 serial_out(up, UART_TX, port->x_char); in serial8250_tx_chars()
1735 __stop_tx(up); in serial8250_tx_chars()
1739 count = up->tx_loadsz; in serial8250_tx_chars()
1741 serial_out(up, UART_TX, xmit->buf[xmit->tail]); in serial8250_tx_chars()
1746 if ((up->capabilities & UART_CAP_HFIFO) && in serial8250_tx_chars()
1747 (serial_in(up, UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY) in serial8250_tx_chars()
1759 if (uart_circ_empty(xmit) && !(up->capabilities & UART_CAP_RPM)) in serial8250_tx_chars()
1760 __stop_tx(up); in serial8250_tx_chars()
1765 unsigned int serial8250_modem_status(struct uart_8250_port *up) in serial8250_modem_status() argument
1767 struct uart_port *port = &up->port; in serial8250_modem_status()
1768 unsigned int status = serial_in(up, UART_MSR); in serial8250_modem_status()
1770 status |= up->msr_saved_flags; in serial8250_modem_status()
1771 up->msr_saved_flags = 0; in serial8250_modem_status()
1772 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI && in serial8250_modem_status()
1790 static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir) in handle_rx_dma() argument
1794 serial8250_rx_dma_flush(up); in handle_rx_dma()
1799 return up->dma->rx_dma(up); in handle_rx_dma()
1809 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_handle_irq() local
1819 if (!up->dma || handle_rx_dma(up, iir)) in serial8250_handle_irq()
1820 status = serial8250_rx_chars(up, status); in serial8250_handle_irq()
1822 serial8250_modem_status(up); in serial8250_handle_irq()
1823 if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE)) in serial8250_handle_irq()
1824 serial8250_tx_chars(up); in serial8250_handle_irq()
1833 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_default_handle_irq() local
1837 serial8250_rpm_get(up); in serial8250_default_handle_irq()
1842 serial8250_rpm_put(up); in serial8250_default_handle_irq()
1883 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_tx_threshold_handle_irq() local
1886 serial8250_tx_chars(up); in serial8250_tx_threshold_handle_irq()
1896 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_tx_empty() local
1900 serial8250_rpm_get(up); in serial8250_tx_empty()
1904 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; in serial8250_tx_empty()
1907 serial8250_rpm_put(up); in serial8250_tx_empty()
1914 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_get_mctrl() local
1918 serial8250_rpm_get(up); in serial8250_do_get_mctrl()
1919 status = serial8250_modem_status(up); in serial8250_do_get_mctrl()
1920 serial8250_rpm_put(up); in serial8250_do_get_mctrl()
1944 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_set_mctrl() local
1958 mcr = (mcr & up->mcr_mask) | up->mcr_force | up->mcr; in serial8250_do_set_mctrl()
1960 serial8250_out_MCR(up, mcr); in serial8250_do_set_mctrl()
1974 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_break_ctl() local
1977 serial8250_rpm_get(up); in serial8250_break_ctl()
1980 up->lcr |= UART_LCR_SBC; in serial8250_break_ctl()
1982 up->lcr &= ~UART_LCR_SBC; in serial8250_break_ctl()
1983 serial_port_out(port, UART_LCR, up->lcr); in serial8250_break_ctl()
1985 serial8250_rpm_put(up); in serial8250_break_ctl()
1991 static void wait_for_xmitr(struct uart_8250_port *up, int bits) in wait_for_xmitr() argument
1997 status = serial_in(up, UART_LSR); in wait_for_xmitr()
1999 up->lsr_saved_flags |= status & LSR_SAVE_FLAGS; in wait_for_xmitr()
2010 if (up->port.flags & UPF_CONS_FLOW) { in wait_for_xmitr()
2012 unsigned int msr = serial_in(up, UART_MSR); in wait_for_xmitr()
2013 up->msr_saved_flags |= msr & MSR_SAVE_FLAGS; in wait_for_xmitr()
2030 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_get_poll_char() local
2034 serial8250_rpm_get(up); in serial8250_get_poll_char()
2045 serial8250_rpm_put(up); in serial8250_get_poll_char()
2054 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_put_poll_char() local
2056 serial8250_rpm_get(up); in serial8250_put_poll_char()
2061 if (up->capabilities & UART_CAP_UUE) in serial8250_put_poll_char()
2066 wait_for_xmitr(up, BOTH_EMPTY); in serial8250_put_poll_char()
2076 wait_for_xmitr(up, BOTH_EMPTY); in serial8250_put_poll_char()
2078 serial8250_rpm_put(up); in serial8250_put_poll_char()
2085 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_startup() local
2092 if (!up->tx_loadsz) in serial8250_do_startup()
2093 up->tx_loadsz = uart_config[port->type].tx_loadsz; in serial8250_do_startup()
2094 if (!up->capabilities) in serial8250_do_startup()
2095 up->capabilities = uart_config[port->type].flags; in serial8250_do_startup()
2096 up->mcr = 0; in serial8250_do_startup()
2098 if (port->iotype != up->cur_iotype) in serial8250_do_startup()
2101 serial8250_rpm_get(up); in serial8250_do_startup()
2104 up->acr = 0; in serial8250_do_startup()
2109 serial_icr_write(up, UART_CSR, 0); /* Reset the UART */ in serial8250_do_startup()
2120 enable_rsa(up); in serial8250_do_startup()
2141 serial8250_clear_fifos(up); in serial8250_do_startup()
2170 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in serial8250_do_startup()
2172 fctr = serial_in(up, UART_FCTR) & ~(UART_FCTR_RX|UART_FCTR_TX); in serial8250_do_startup()
2190 if ((up->tx_loadsz < 2) || (up->tx_loadsz > port->fifosize)) { in serial8250_do_startup()
2197 port->fifosize - up->tx_loadsz); in serial8250_do_startup()
2213 if (up->port.irqflags & IRQF_SHARED) in serial8250_do_startup()
2216 wait_for_xmitr(up, UART_LSR_THRE); in serial8250_do_startup()
2236 up->port.flags & UPF_BUG_THRE) { in serial8250_do_startup()
2237 up->bugs |= UART_BUG_THRE; in serial8250_do_startup()
2241 retval = up->ops->setup_irq(up); in serial8250_do_startup()
2251 if (up->port.flags & UPF_FOURPORT) { in serial8250_do_startup()
2252 if (!up->port.irq) in serial8250_do_startup()
2253 up->port.mctrl |= TIOCM_OUT1; in serial8250_do_startup()
2259 up->port.mctrl |= TIOCM_OUT2; in serial8250_do_startup()
2274 if (up->port.flags & UPF_NO_TXEN_TEST) in serial8250_do_startup()
2287 if (!(up->bugs & UART_BUG_TXEN)) { in serial8250_do_startup()
2288 up->bugs |= UART_BUG_TXEN; in serial8250_do_startup()
2293 up->bugs &= ~UART_BUG_TXEN; in serial8250_do_startup()
2308 up->lsr_saved_flags = 0; in serial8250_do_startup()
2309 up->msr_saved_flags = 0; in serial8250_do_startup()
2314 if (up->dma) { in serial8250_do_startup()
2315 retval = serial8250_request_dma(up); in serial8250_do_startup()
2319 up->dma = NULL; in serial8250_do_startup()
2328 up->ier = UART_IER_RLSI | UART_IER_RDI; in serial8250_do_startup()
2341 serial8250_rpm_put(up); in serial8250_do_startup()
2355 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_shutdown() local
2358 serial8250_rpm_get(up); in serial8250_do_shutdown()
2363 up->ier = 0; in serial8250_do_shutdown()
2369 if (up->dma) in serial8250_do_shutdown()
2370 serial8250_release_dma(up); in serial8250_do_shutdown()
2388 serial8250_clear_fifos(up); in serial8250_do_shutdown()
2394 disable_rsa(up); in serial8250_do_shutdown()
2402 serial8250_rpm_put(up); in serial8250_do_shutdown()
2404 up->ops->release_irq(up); in serial8250_do_shutdown()
2420 static unsigned int xr17v35x_get_divisor(struct uart_8250_port *up, in xr17v35x_get_divisor() argument
2424 struct uart_port *port = &up->port; in xr17v35x_get_divisor()
2433 static unsigned int serial8250_get_divisor(struct uart_8250_port *up, in serial8250_get_divisor() argument
2437 struct uart_port *port = &up->port; in serial8250_get_divisor()
2451 else if (up->port.type == PORT_XR17V35X) in serial8250_get_divisor()
2452 quot = xr17v35x_get_divisor(up, baud, frac); in serial8250_get_divisor()
2459 if (up->bugs & UART_BUG_QUOT && (quot & 0xff) == 0) in serial8250_get_divisor()
2465 static unsigned char serial8250_compute_lcr(struct uart_8250_port *up, in serial8250_compute_lcr() argument
2490 if (up->bugs & UART_BUG_PARITY) in serial8250_compute_lcr()
2491 up->fifo_bug = true; in serial8250_compute_lcr()
2506 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_set_divisor() local
2509 if (is_omap1510_8250(up)) { in serial8250_set_divisor()
2521 if (up->capabilities & UART_NATSEMI) in serial8250_set_divisor()
2524 serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB); in serial8250_set_divisor()
2526 serial_dl_write(up, quot); in serial8250_set_divisor()
2529 if (up->port.type == PORT_XR17V35X) { in serial8250_set_divisor()
2555 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_do_set_termios() local
2560 cval = serial8250_compute_lcr(up, termios->c_cflag); in serial8250_do_set_termios()
2563 quot = serial8250_get_divisor(up, baud, &frac); in serial8250_do_set_termios()
2569 serial8250_rpm_get(up); in serial8250_do_set_termios()
2572 up->lcr = cval; /* Save computed LCR */ in serial8250_do_set_termios()
2574 if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) { in serial8250_do_set_termios()
2576 if ((baud < 2400 && !up->dma) || up->fifo_bug) { in serial8250_do_set_termios()
2577 up->fcr &= ~UART_FCR_TRIGGER_MASK; in serial8250_do_set_termios()
2578 up->fcr |= UART_FCR_TRIGGER_1; in serial8250_do_set_termios()
2587 if (up->capabilities & UART_CAP_AFE) { in serial8250_do_set_termios()
2588 up->mcr &= ~UART_MCR_AFE; in serial8250_do_set_termios()
2590 up->mcr |= UART_MCR_AFE; in serial8250_do_set_termios()
2629 up->ier &= ~UART_IER_MSI; in serial8250_do_set_termios()
2630 if (!(up->bugs & UART_BUG_NOMSR) && in serial8250_do_set_termios()
2631 UART_ENABLE_MS(&up->port, termios->c_cflag)) in serial8250_do_set_termios()
2632 up->ier |= UART_IER_MSI; in serial8250_do_set_termios()
2633 if (up->capabilities & UART_CAP_UUE) in serial8250_do_set_termios()
2634 up->ier |= UART_IER_UUE; in serial8250_do_set_termios()
2635 if (up->capabilities & UART_CAP_RTOIE) in serial8250_do_set_termios()
2636 up->ier |= UART_IER_RTOIE; in serial8250_do_set_termios()
2638 serial_port_out(port, UART_IER, up->ier); in serial8250_do_set_termios()
2640 if (up->capabilities & UART_CAP_EFR) { in serial8250_do_set_termios()
2664 serial_port_out(port, UART_FCR, up->fcr); in serial8250_do_set_termios()
2666 serial_port_out(port, UART_LCR, up->lcr); /* reset DLAB */ in serial8250_do_set_termios()
2669 if (up->fcr & UART_FCR_ENABLE_FIFO) in serial8250_do_set_termios()
2671 serial_port_out(port, UART_FCR, up->fcr); /* set fcr */ in serial8250_do_set_termios()
2675 serial8250_rpm_put(up); in serial8250_do_set_termios()
2749 static int serial8250_request_std_resource(struct uart_8250_port *up) in serial8250_request_std_resource() argument
2751 unsigned int size = serial8250_port_size(up); in serial8250_request_std_resource()
2752 struct uart_port *port = &up->port; in serial8250_request_std_resource()
2788 static void serial8250_release_std_resource(struct uart_8250_port *up) in serial8250_release_std_resource() argument
2790 unsigned int size = serial8250_port_size(up); in serial8250_release_std_resource()
2791 struct uart_port *port = &up->port; in serial8250_release_std_resource()
2820 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_release_port() local
2822 serial8250_release_std_resource(up); in serial8250_release_port()
2827 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_request_port() local
2829 return serial8250_request_std_resource(up); in serial8250_request_port()
2832 static int fcr_get_rxtrig_bytes(struct uart_8250_port *up) in fcr_get_rxtrig_bytes() argument
2834 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in fcr_get_rxtrig_bytes()
2837 bytes = conf_type->rxtrig_bytes[UART_FCR_R_TRIG_BITS(up->fcr)]; in fcr_get_rxtrig_bytes()
2842 static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, unsigned char bytes) in bytes_to_fcr_rxtrig() argument
2844 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in bytes_to_fcr_rxtrig()
2863 struct uart_8250_port *up = up_to_u8250p(uport); in do_get_rxtrig() local
2865 if (!(up->capabilities & UART_CAP_FIFO) || uport->fifosize <= 1) in do_get_rxtrig()
2868 return fcr_get_rxtrig_bytes(up); in do_get_rxtrig()
2899 struct uart_8250_port *up = up_to_u8250p(uport); in do_set_rxtrig() local
2902 if (!(up->capabilities & UART_CAP_FIFO) || uport->fifosize <= 1 || in do_set_rxtrig()
2903 up->fifo_bug) in do_set_rxtrig()
2906 rxtrig = bytes_to_fcr_rxtrig(up, bytes); in do_set_rxtrig()
2910 serial8250_clear_fifos(up); in do_set_rxtrig()
2911 up->fcr &= ~UART_FCR_TRIGGER_MASK; in do_set_rxtrig()
2912 up->fcr |= (unsigned char)rxtrig; in do_set_rxtrig()
2913 serial_out(up, UART_FCR, up->fcr); in do_set_rxtrig()
2962 static void register_dev_spec_attr_grp(struct uart_8250_port *up) in register_dev_spec_attr_grp() argument
2964 const struct serial8250_config *conf_type = &uart_config[up->port.type]; in register_dev_spec_attr_grp()
2967 up->port.attr_group = &serial8250_dev_attr_group; in register_dev_spec_attr_grp()
2972 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_config_port() local
2979 ret = serial8250_request_std_resource(up); in serial8250_config_port()
2983 if (port->iotype != up->cur_iotype) in serial8250_config_port()
2987 autoconfig(up); in serial8250_config_port()
2991 up->bugs |= UART_BUG_NOMSR; in serial8250_config_port()
2995 up->bugs |= UART_BUG_NOMSR; in serial8250_config_port()
2998 autoconfig_irq(up); in serial8250_config_port()
3001 serial8250_release_std_resource(up); in serial8250_config_port()
3008 register_dev_spec_attr_grp(up); in serial8250_config_port()
3009 up->fcr = uart_config[up->port.type].fcr; in serial8250_config_port()
3059 void serial8250_init_port(struct uart_8250_port *up) in serial8250_init_port() argument
3061 struct uart_port *port = &up->port; in serial8250_init_port()
3066 up->cur_iotype = 0xFF; in serial8250_init_port()
3070 void serial8250_set_defaults(struct uart_8250_port *up) in serial8250_set_defaults() argument
3072 struct uart_port *port = &up->port; in serial8250_set_defaults()
3074 if (up->port.flags & UPF_FIXED_TYPE) { in serial8250_set_defaults()
3075 unsigned int type = up->port.type; in serial8250_set_defaults()
3077 if (!up->port.fifosize) in serial8250_set_defaults()
3078 up->port.fifosize = uart_config[type].fifo_size; in serial8250_set_defaults()
3079 if (!up->tx_loadsz) in serial8250_set_defaults()
3080 up->tx_loadsz = uart_config[type].tx_loadsz; in serial8250_set_defaults()
3081 if (!up->capabilities) in serial8250_set_defaults()
3082 up->capabilities = uart_config[type].flags; in serial8250_set_defaults()
3088 if (up->dma) { in serial8250_set_defaults()
3089 if (!up->dma->tx_dma) in serial8250_set_defaults()
3090 up->dma->tx_dma = serial8250_tx_dma; in serial8250_set_defaults()
3091 if (!up->dma->rx_dma) in serial8250_set_defaults()
3092 up->dma->rx_dma = serial8250_rx_dma; in serial8250_set_defaults()
3101 struct uart_8250_port *up = up_to_u8250p(port); in serial8250_console_putchar() local
3103 wait_for_xmitr(up, UART_LSR_THRE); in serial8250_console_putchar()
3110 static void serial8250_console_restore(struct uart_8250_port *up) in serial8250_console_restore() argument
3112 struct uart_port *port = &up->port; in serial8250_console_restore()
3121 quot = serial8250_get_divisor(up, baud, &frac); in serial8250_console_restore()
3124 serial_port_out(port, UART_LCR, up->lcr); in serial8250_console_restore()
3125 serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS); in serial8250_console_restore()
3134 void serial8250_console_write(struct uart_8250_port *up, const char *s, in serial8250_console_write() argument
3137 struct uart_port *port = &up->port; in serial8250_console_write()
3144 serial8250_rpm_get(up); in serial8250_console_write()
3158 if (up->capabilities & UART_CAP_UUE) in serial8250_console_write()
3164 if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) { in serial8250_console_write()
3165 serial8250_console_restore(up); in serial8250_console_write()
3166 up->canary = 0; in serial8250_console_write()
3175 wait_for_xmitr(up, BOTH_EMPTY); in serial8250_console_write()
3185 if (up->msr_saved_flags) in serial8250_console_write()
3186 serial8250_modem_status(up); in serial8250_console_write()
3190 serial8250_rpm_put(up); in serial8250_console_write()