Lines Matching full:up
178 struct uart_8250_port *up = up_to_u8250p(port); in __omap8250_set_mctrl() local
179 struct omap8250_priv *priv = up->port.private_data; in __omap8250_set_mctrl()
184 if (!mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_RTS)) { in __omap8250_set_mctrl()
189 lcr = serial_in(up, UART_LCR); in __omap8250_set_mctrl()
190 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in __omap8250_set_mctrl()
195 serial_out(up, UART_EFR, priv->efr); in __omap8250_set_mctrl()
196 serial_out(up, UART_LCR, lcr); in __omap8250_set_mctrl()
223 static void omap_8250_mdr1_errataset(struct uart_8250_port *up, in omap_8250_mdr1_errataset() argument
226 serial_out(up, UART_OMAP_MDR1, priv->mdr1); in omap_8250_mdr1_errataset()
228 serial_out(up, UART_FCR, up->fcr | UART_FCR_CLEAR_XMIT | in omap_8250_mdr1_errataset()
275 static void omap8250_update_scr(struct uart_8250_port *up, in omap8250_update_scr() argument
280 old_scr = serial_in(up, UART_OMAP_SCR); in omap8250_update_scr()
290 serial_out(up, UART_OMAP_SCR, in omap8250_update_scr()
292 serial_out(up, UART_OMAP_SCR, priv->scr); in omap8250_update_scr()
295 static void omap8250_update_mdr1(struct uart_8250_port *up, in omap8250_update_mdr1() argument
299 omap_8250_mdr1_errataset(up, priv); in omap8250_update_mdr1()
301 serial_out(up, UART_OMAP_MDR1, priv->mdr1); in omap8250_update_mdr1()
304 static void omap8250_restore_regs(struct uart_8250_port *up) in omap8250_restore_regs() argument
306 struct omap8250_priv *priv = up->port.private_data; in omap8250_restore_regs()
307 struct uart_8250_dma *dma = up->dma; in omap8250_restore_regs()
308 u8 mcr = serial8250_in_MCR(up); in omap8250_restore_regs()
311 lockdep_assert_held_once(&up->port.lock); in omap8250_restore_regs()
324 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in omap8250_restore_regs()
325 serial_out(up, UART_EFR, UART_EFR_ECB); in omap8250_restore_regs()
327 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); in omap8250_restore_regs()
328 serial8250_out_MCR(up, mcr | UART_MCR_TCRTLR); in omap8250_restore_regs()
329 serial_out(up, UART_FCR, up->fcr); in omap8250_restore_regs()
331 omap8250_update_scr(up, priv); in omap8250_restore_regs()
333 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in omap8250_restore_regs()
335 serial_out(up, UART_TI752_TCR, OMAP_UART_TCR_RESTORE(16) | in omap8250_restore_regs()
337 serial_out(up, UART_TI752_TLR, in omap8250_restore_regs()
341 serial_out(up, UART_LCR, 0); in omap8250_restore_regs()
344 serial8250_out_MCR(up, mcr); in omap8250_restore_regs()
346 serial_out(up, UART_IER, up->ier); in omap8250_restore_regs()
348 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in omap8250_restore_regs()
349 serial_dl_write(up, priv->quot); in omap8250_restore_regs()
351 serial_out(up, UART_EFR, priv->efr); in omap8250_restore_regs()
354 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in omap8250_restore_regs()
355 serial_out(up, UART_XON1, priv->xon); in omap8250_restore_regs()
356 serial_out(up, UART_XOFF1, priv->xoff); in omap8250_restore_regs()
358 serial_out(up, UART_LCR, up->lcr); in omap8250_restore_regs()
360 omap8250_update_mdr1(up, priv); in omap8250_restore_regs()
362 __omap8250_set_mctrl(&up->port, up->port.mctrl); in omap8250_restore_regs()
364 serial_out(up, UART_OMAP_MDR3, priv->mdr3); in omap8250_restore_regs()
366 if (up->port.rs485.flags & SER_RS485_ENABLED && in omap8250_restore_regs()
367 up->port.rs485_config == serial8250_em485_config) in omap8250_restore_regs()
368 serial8250_em485_stop_tx(up); in omap8250_restore_regs()
379 struct uart_8250_port *up = up_to_u8250p(port); in omap_8250_set_termios() local
380 struct omap8250_priv *priv = up->port.private_data; in omap_8250_set_termios()
415 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; in omap_8250_set_termios()
417 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE; in omap_8250_set_termios()
419 up->port.read_status_mask |= UART_LSR_BI; in omap_8250_set_termios()
424 up->port.ignore_status_mask = 0; in omap_8250_set_termios()
426 up->port.ignore_status_mask |= UART_LSR_PE | UART_LSR_FE; in omap_8250_set_termios()
428 up->port.ignore_status_mask |= UART_LSR_BI; in omap_8250_set_termios()
434 up->port.ignore_status_mask |= UART_LSR_OE; in omap_8250_set_termios()
441 up->port.ignore_status_mask |= UART_LSR_DR; in omap_8250_set_termios()
446 up->ier &= ~UART_IER_MSI; in omap_8250_set_termios()
447 if (UART_ENABLE_MS(&up->port, termios->c_cflag)) in omap_8250_set_termios()
448 up->ier |= UART_IER_MSI; in omap_8250_set_termios()
450 up->lcr = cval; in omap_8250_set_termios()
451 /* Up to here it was mostly serial8250_do_set_termios() */ in omap_8250_set_termios()
470 up->fcr = UART_FCR_ENABLE_FIFO; in omap_8250_set_termios()
471 up->fcr |= TRIGGER_FCR_MASK(priv->tx_trigger) << OMAP_UART_FCR_TX_TRIG; in omap_8250_set_termios()
472 up->fcr |= TRIGGER_FCR_MASK(priv->rx_trigger) << OMAP_UART_FCR_RX_TRIG; in omap_8250_set_termios()
477 if (up->dma) in omap_8250_set_termios()
485 up->port.status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF); in omap_8250_set_termios()
487 if (termios->c_cflag & CRTSCTS && up->port.flags & UPF_HARD_FLOW && in omap_8250_set_termios()
488 !mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_RTS) && in omap_8250_set_termios()
489 !mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_CTS)) { in omap_8250_set_termios()
491 up->port.status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS; in omap_8250_set_termios()
493 } else if (up->port.flags & UPF_SOFT_FLOW) { in omap_8250_set_termios()
505 up->port.status |= UPSTAT_AUTOXOFF; in omap_8250_set_termios()
509 omap8250_restore_regs(up); in omap_8250_set_termios()
511 uart_port_unlock_irq(&up->port); in omap_8250_set_termios()
530 struct uart_8250_port *up = up_to_u8250p(port); in omap_8250_pm() local
538 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in omap_8250_pm()
539 efr = serial_in(up, UART_EFR); in omap_8250_pm()
540 serial_out(up, UART_EFR, efr | UART_EFR_ECB); in omap_8250_pm()
541 serial_out(up, UART_LCR, 0); in omap_8250_pm()
543 serial_out(up, UART_IER, (state != 0) ? UART_IERX_SLEEP : 0); in omap_8250_pm()
544 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); in omap_8250_pm()
545 serial_out(up, UART_EFR, efr); in omap_8250_pm()
546 serial_out(up, UART_LCR, 0); in omap_8250_pm()
554 static void omap_serial_fill_features_erratas(struct uart_8250_port *up, in omap_serial_fill_features_erratas() argument
585 dev_warn(up->port.dev, in omap_serial_fill_features_erratas()
634 struct uart_8250_port *up = serial8250_get_port(priv->line); in omap8250_irq() local
635 struct uart_port *port = &up->port; in omap8250_irq()
641 /* Shallow idle state wake-up to an IO interrupt? */ in omap8250_irq()
648 if (up->dma) { in omap8250_irq()
671 efr2 = serial_in(up, UART_OMAP_EFR2); in omap8250_irq()
672 timeout_h = serial_in(up, UART_OMAP_TO_H); in omap8250_irq()
673 timeout_l = serial_in(up, UART_OMAP_TO_L); in omap8250_irq()
674 serial_out(up, UART_OMAP_TO_H, 0xFF); in omap8250_irq()
675 serial_out(up, UART_OMAP_TO_L, 0xFF); in omap8250_irq()
676 serial_out(up, UART_OMAP_EFR2, UART_OMAP_EFR2_TIMEOUT_BEHAVE); in omap8250_irq()
677 serial_in(up, UART_IIR); in omap8250_irq()
678 serial_out(up, UART_OMAP_EFR2, efr2); in omap8250_irq()
679 serial_out(up, UART_OMAP_TO_H, timeout_h); in omap8250_irq()
680 serial_out(up, UART_OMAP_TO_L, timeout_l); in omap8250_irq()
684 if ((lsr & UART_LSR_OE) && up->overrun_backoff_time_ms > 0) { in omap8250_irq()
689 up->ier = port->serial_in(port, UART_IER); in omap8250_irq()
690 if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) { in omap8250_irq()
696 cancel_delayed_work(&up->overrun_backoff); in omap8250_irq()
700 delay = msecs_to_jiffies(up->overrun_backoff_time_ms); in omap8250_irq()
701 schedule_delayed_work(&up->overrun_backoff, delay); in omap8250_irq()
712 struct uart_8250_port *up = up_to_u8250p(port); in omap_8250_startup() local
725 serial_out(up, UART_FCR, UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); in omap_8250_startup()
727 serial_out(up, UART_LCR, UART_LCR_WLEN8); in omap_8250_startup()
729 up->lsr_saved_flags = 0; in omap_8250_startup()
730 up->msr_saved_flags = 0; in omap_8250_startup()
734 up->dma = &priv->omap8250_dma; in omap_8250_startup()
735 ret = serial8250_request_dma(up); in omap_8250_startup()
739 up->dma = NULL; in omap_8250_startup()
742 up->dma = NULL; in omap_8250_startup()
747 up->ier = UART_IER_RLSI | UART_IER_RDI; in omap_8250_startup()
748 serial_out(up, UART_IER, up->ier); in omap_8250_startup()
752 up->capabilities |= UART_CAP_RPM; in omap_8250_startup()
755 /* Enable module level wake up */ in omap_8250_startup()
759 serial_out(up, UART_OMAP_WER, priv->wer); in omap_8250_startup()
761 if (up->dma && !(priv->habit & UART_HAS_EFR2)) { in omap_8250_startup()
763 up->dma->rx_dma(up); in omap_8250_startup()
767 enable_irq(up->port.irq); in omap_8250_startup()
776 struct uart_8250_port *up = up_to_u8250p(port); in omap_8250_shutdown() local
780 if (up->dma) in omap_8250_shutdown()
781 omap_8250_rx_dma_flush(up); in omap_8250_shutdown()
785 serial_out(up, UART_OMAP_WER, 0); in omap_8250_shutdown()
787 serial_out(up, UART_OMAP_EFR2, 0x0); in omap_8250_shutdown()
791 up->ier = 0; in omap_8250_shutdown()
792 serial_out(up, UART_IER, 0); in omap_8250_shutdown()
794 disable_irq_nosync(up->port.irq); in omap_8250_shutdown()
797 serial8250_release_dma(up); in omap_8250_shutdown()
798 up->dma = NULL; in omap_8250_shutdown()
803 if (up->lcr & UART_LCR_SBC) in omap_8250_shutdown()
804 serial_out(up, UART_LCR, up->lcr & ~UART_LCR_SBC); in omap_8250_shutdown()
805 serial_out(up, UART_FCR, UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); in omap_8250_shutdown()
830 struct uart_8250_port *up = up_to_u8250p(port); in omap_8250_unthrottle() local
838 if (up->dma) in omap_8250_unthrottle()
839 up->dma->rx_dma(up); in omap_8250_unthrottle()
840 up->ier |= UART_IER_RLSI | UART_IER_RDI; in omap_8250_unthrottle()
842 serial_out(up, UART_IER, up->ier); in omap_8250_unthrottle()
854 struct uart_8250_port *up = up_to_u8250p(port); in omap8250_rs485_config() local
885 mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_RTS) || in omap8250_rs485_config()
889 serial_out(up, UART_OMAP_MDR3, priv->mdr3); in omap8250_rs485_config()
912 serial_out(up, UART_OMAP_MDR3, priv->mdr3); in omap8250_rs485_config()
1251 static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir) in handle_rx_dma() argument
1257 omap_8250_rx_dma_flush(up); in handle_rx_dma()
1260 return omap_8250_rx_dma(up); in handle_rx_dma()
1263 static u16 omap_8250_handle_rx_dma(struct uart_8250_port *up, u8 iir, u16 status) in omap_8250_handle_rx_dma() argument
1267 if (handle_rx_dma(up, iir)) { in omap_8250_handle_rx_dma()
1268 status = serial8250_rx_chars(up, status); in omap_8250_handle_rx_dma()
1269 omap_8250_rx_dma(up); in omap_8250_handle_rx_dma()
1276 static void am654_8250_handle_rx_dma(struct uart_8250_port *up, u8 iir, in am654_8250_handle_rx_dma() argument
1280 lockdep_assert_held_once(&up->port.lock); in am654_8250_handle_rx_dma()
1286 (up->ier & UART_IER_RDI)) { in am654_8250_handle_rx_dma()
1287 omap_8250_rx_dma(up); in am654_8250_handle_rx_dma()
1288 serial_out(up, UART_OMAP_EFR2, UART_OMAP_EFR2_TIMEOUT_BEHAVE); in am654_8250_handle_rx_dma()
1295 up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); in am654_8250_handle_rx_dma()
1296 serial_out(up, UART_IER, up->ier); in am654_8250_handle_rx_dma()
1297 omap_8250_rx_dma_flush(up); in am654_8250_handle_rx_dma()
1298 serial_in(up, UART_IIR); in am654_8250_handle_rx_dma()
1299 serial_out(up, UART_OMAP_EFR2, 0x0); in am654_8250_handle_rx_dma()
1300 up->ier |= UART_IER_RLSI | UART_IER_RDI; in am654_8250_handle_rx_dma()
1301 serial_out(up, UART_IER, up->ier); in am654_8250_handle_rx_dma()
1312 struct uart_8250_port *up = up_to_u8250p(port); in omap_8250_dma_handle_irq() local
1313 struct omap8250_priv *priv = up->port.private_data; in omap_8250_dma_handle_irq()
1328 am654_8250_handle_rx_dma(up, iir, status); in omap_8250_dma_handle_irq()
1330 status = omap_8250_handle_rx_dma(up, iir, status); in omap_8250_dma_handle_irq()
1333 serial8250_modem_status(up); in omap_8250_dma_handle_irq()
1334 if (status & UART_LSR_THRE && up->dma->tx_err) { in omap_8250_dma_handle_irq()
1335 if (uart_tx_stopped(&up->port) || in omap_8250_dma_handle_irq()
1336 kfifo_is_empty(&up->port.state->port.xmit_fifo)) { in omap_8250_dma_handle_irq()
1337 up->dma->tx_err = 0; in omap_8250_dma_handle_irq()
1338 serial8250_tx_chars(up); in omap_8250_dma_handle_irq()
1344 if (omap_8250_tx_dma(up)) in omap_8250_dma_handle_irq()
1345 serial8250_tx_chars(up); in omap_8250_dma_handle_irq()
1419 struct uart_8250_port up; in omap8250_probe() local
1439 memset(&up, 0, sizeof(up)); in omap8250_probe()
1440 up.port.dev = &pdev->dev; in omap8250_probe()
1441 up.port.mapbase = regs->start; in omap8250_probe()
1442 up.port.membase = membase; in omap8250_probe()
1451 up.port.type = PORT_8250; in omap8250_probe()
1452 up.port.flags = UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_SOFT_FLOW | UPF_HARD_FLOW; in omap8250_probe()
1453 up.port.private_data = priv; in omap8250_probe()
1455 up.tx_loadsz = 64; in omap8250_probe()
1456 up.capabilities = UART_CAP_FIFO; in omap8250_probe()
1464 up.capabilities |= UART_CAP_RPM; in omap8250_probe()
1466 up.port.set_termios = omap_8250_set_termios; in omap8250_probe()
1467 up.port.set_mctrl = omap8250_set_mctrl; in omap8250_probe()
1468 up.port.pm = omap_8250_pm; in omap8250_probe()
1469 up.port.startup = omap_8250_startup; in omap8250_probe()
1470 up.port.shutdown = omap_8250_shutdown; in omap8250_probe()
1471 up.port.throttle = omap_8250_throttle; in omap8250_probe()
1472 up.port.unthrottle = omap_8250_unthrottle; in omap8250_probe()
1473 up.port.rs485_config = omap8250_rs485_config; in omap8250_probe()
1475 up.port.rs485_supported = serial8250_em485_supported; in omap8250_probe()
1476 up.rs485_start_tx = serial8250_em485_start_tx; in omap8250_probe()
1477 up.rs485_stop_tx = serial8250_em485_stop_tx; in omap8250_probe()
1478 up.port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE); in omap8250_probe()
1480 ret = uart_read_port_properties(&up.port); in omap8250_probe()
1484 up.port.regshift = OMAP_UART_REGSHIFT; in omap8250_probe()
1485 up.port.fifosize = 64; in omap8250_probe()
1487 if (!up.port.uartclk) { in omap8250_probe()
1495 up.port.uartclk = clk_get_rate(clk); in omap8250_probe()
1500 &up.overrun_backoff_time_ms) != 0) in omap8250_probe()
1501 up.overrun_backoff_time_ms = 0; in omap8250_probe()
1507 if (!up.port.uartclk) { in omap8250_probe()
1508 up.port.uartclk = DEFAULT_CLK_SPEED; in omap8250_probe()
1535 * prevent an unsafe default policy with lossy characters on wake-up. in omap8250_probe()
1544 omap_serial_fill_features_erratas(&up, priv); in omap8250_probe()
1545 up.port.handle_irq = omap8250_no_handle_irq; in omap8250_probe()
1582 irq_set_status_flags(up.port.irq, IRQ_NOAUTOEN); in omap8250_probe()
1583 ret = devm_request_irq(&pdev->dev, up.port.irq, omap8250_irq, 0, in omap8250_probe()
1590 ret = serial8250_register_8250_port(&up); in omap8250_probe()
1611 struct uart_8250_port *up; in omap8250_remove() local
1618 up = serial8250_get_port(priv->line); in omap8250_remove()
1619 omap_8250_shutdown(&up->port); in omap8250_remove()
1652 struct uart_8250_port *up = serial8250_get_port(priv->line); in omap8250_suspend() local
1662 serial_out(up, UART_OMAP_WER, priv->wer); in omap8250_suspend()
1663 if (uart_console(&up->port) && console_suspend_enabled) in omap8250_suspend()
1673 struct uart_8250_port *up = serial8250_get_port(priv->line); in omap8250_resume() local
1676 if (uart_console(&up->port) && console_suspend_enabled) { in omap8250_resume()
1690 static int omap8250_lost_context(struct uart_8250_port *up) in omap8250_lost_context() argument
1694 val = serial_in(up, UART_OMAP_SCR); in omap8250_lost_context()
1754 struct uart_8250_port *up = NULL; in omap8250_runtime_suspend() local
1757 up = serial8250_get_port(priv->line); in omap8250_runtime_suspend()
1766 if (up) { in omap8250_runtime_suspend()
1768 omap8250_update_mdr1(up, priv); in omap8250_runtime_suspend()
1770 serial_out(up, UART_OMAP_WER, priv->wer); in omap8250_runtime_suspend()
1774 if (up && up->dma && up->dma->rxchan) in omap8250_runtime_suspend()
1775 omap_8250_rx_dma_flush(up); in omap8250_runtime_suspend()
1787 struct uart_8250_port *up = NULL; in omap8250_runtime_resume() local
1794 up = serial8250_get_port(priv->line); in omap8250_runtime_resume()
1796 if (up && omap8250_lost_context(up)) { in omap8250_runtime_resume()
1797 uart_port_lock_irq(&up->port); in omap8250_runtime_resume()
1798 omap8250_restore_regs(up); in omap8250_runtime_resume()
1799 uart_port_unlock_irq(&up->port); in omap8250_runtime_resume()
1802 if (up && up->dma && up->dma->rxchan && !(priv->habit & UART_HAS_EFR2)) { in omap8250_runtime_resume()
1803 uart_port_lock_irq(&up->port); in omap8250_runtime_resume()
1804 omap_8250_rx_dma(up); in omap8250_runtime_resume()
1805 uart_port_unlock_irq(&up->port); in omap8250_runtime_resume()