• Home
  • Raw
  • Download

Lines Matching refs:port

72 #define SCIx_IRQ_IS_MUXED(port)			\  argument
73 ((port)->irqs[SCIx_ERI_IRQ] == \
74 (port)->irqs[SCIx_RXI_IRQ]) || \
75 ((port)->irqs[SCIx_ERI_IRQ] && \
76 ((port)->irqs[SCIx_RXI_IRQ] < 0))
79 struct uart_port port; member
128 return container_of(uart, struct sci_port, port); in to_sci_port()
451 if (!sci_port->port.dev) in sci_port_enable()
454 pm_runtime_get_sync(sci_port->port.dev); in sci_port_enable()
457 sci_port->port.uartclk = clk_get_rate(sci_port->iclk); in sci_port_enable()
463 if (!sci_port->port.dev) in sci_port_disable()
477 pm_runtime_put_sync(sci_port->port.dev); in sci_port_disable()
480 static inline unsigned long port_rx_irq_mask(struct uart_port *port) in port_rx_irq_mask() argument
489 return SCSCR_RIE | (to_sci_port(port)->cfg->scscr & SCSCR_REIE); in port_rx_irq_mask()
492 static void sci_start_tx(struct uart_port *port) in sci_start_tx() argument
494 struct sci_port *s = to_sci_port(port); in sci_start_tx()
498 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { in sci_start_tx()
499 u16 new, scr = serial_port_in(port, SCSCR); in sci_start_tx()
505 serial_port_out(port, SCSCR, new); in sci_start_tx()
508 if (s->chan_tx && !uart_circ_empty(&s->port.state->xmit) && in sci_start_tx()
515 if (!s->chan_tx || port->type == PORT_SCIFA || port->type == PORT_SCIFB) { in sci_start_tx()
517 ctrl = serial_port_in(port, SCSCR); in sci_start_tx()
518 serial_port_out(port, SCSCR, ctrl | SCSCR_TIE); in sci_start_tx()
522 static void sci_stop_tx(struct uart_port *port) in sci_stop_tx() argument
527 ctrl = serial_port_in(port, SCSCR); in sci_stop_tx()
529 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) in sci_stop_tx()
534 serial_port_out(port, SCSCR, ctrl); in sci_stop_tx()
537 static void sci_start_rx(struct uart_port *port) in sci_start_rx() argument
541 ctrl = serial_port_in(port, SCSCR) | port_rx_irq_mask(port); in sci_start_rx()
543 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) in sci_start_rx()
546 serial_port_out(port, SCSCR, ctrl); in sci_start_rx()
549 static void sci_stop_rx(struct uart_port *port) in sci_stop_rx() argument
553 ctrl = serial_port_in(port, SCSCR); in sci_stop_rx()
555 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) in sci_stop_rx()
558 ctrl &= ~port_rx_irq_mask(port); in sci_stop_rx()
560 serial_port_out(port, SCSCR, ctrl); in sci_stop_rx()
563 static void sci_clear_SCxSR(struct uart_port *port, unsigned int mask) in sci_clear_SCxSR() argument
565 if (port->type == PORT_SCI) { in sci_clear_SCxSR()
567 serial_port_out(port, SCxSR, mask); in sci_clear_SCxSR()
568 } else if (to_sci_port(port)->overrun_mask == SCIFA_ORER) { in sci_clear_SCxSR()
571 serial_port_out(port, SCxSR, in sci_clear_SCxSR()
572 serial_port_in(port, SCxSR) & mask); in sci_clear_SCxSR()
575 serial_port_out(port, SCxSR, mask & ~(SCIF_FERC | SCIF_PERC)); in sci_clear_SCxSR()
582 static int sci_poll_get_char(struct uart_port *port) in sci_poll_get_char() argument
588 status = serial_port_in(port, SCxSR); in sci_poll_get_char()
589 if (status & SCxSR_ERRORS(port)) { in sci_poll_get_char()
590 sci_clear_SCxSR(port, SCxSR_ERROR_CLEAR(port)); in sci_poll_get_char()
596 if (!(status & SCxSR_RDxF(port))) in sci_poll_get_char()
599 c = serial_port_in(port, SCxRDR); in sci_poll_get_char()
602 serial_port_in(port, SCxSR); in sci_poll_get_char()
603 sci_clear_SCxSR(port, SCxSR_RDxF_CLEAR(port)); in sci_poll_get_char()
609 static void sci_poll_put_char(struct uart_port *port, unsigned char c) in sci_poll_put_char() argument
614 status = serial_port_in(port, SCxSR); in sci_poll_put_char()
615 } while (!(status & SCxSR_TDxE(port))); in sci_poll_put_char()
617 serial_port_out(port, SCxTDR, c); in sci_poll_put_char()
618 sci_clear_SCxSR(port, SCxSR_TDxE_CLEAR(port) & ~SCxSR_TEND(port)); in sci_poll_put_char()
622 static void sci_init_pins(struct uart_port *port, unsigned int cflag) in sci_init_pins() argument
624 struct sci_port *s = to_sci_port(port); in sci_init_pins()
631 s->cfg->ops->init_pins(port, cflag); in sci_init_pins()
646 status = serial_port_in(port, SCSPTR); in sci_init_pins()
649 serial_port_out(port, SCSPTR, status); /* Set RTS = 1 */ in sci_init_pins()
653 static int sci_txfill(struct uart_port *port) in sci_txfill() argument
657 reg = sci_getreg(port, SCTFDR); in sci_txfill()
659 return serial_port_in(port, SCTFDR) & ((port->fifosize << 1) - 1); in sci_txfill()
661 reg = sci_getreg(port, SCFDR); in sci_txfill()
663 return serial_port_in(port, SCFDR) >> 8; in sci_txfill()
665 return !(serial_port_in(port, SCxSR) & SCI_TDRE); in sci_txfill()
668 static int sci_txroom(struct uart_port *port) in sci_txroom() argument
670 return port->fifosize - sci_txfill(port); in sci_txroom()
673 static int sci_rxfill(struct uart_port *port) in sci_rxfill() argument
677 reg = sci_getreg(port, SCRFDR); in sci_rxfill()
679 return serial_port_in(port, SCRFDR) & ((port->fifosize << 1) - 1); in sci_rxfill()
681 reg = sci_getreg(port, SCFDR); in sci_rxfill()
683 return serial_port_in(port, SCFDR) & ((port->fifosize << 1) - 1); in sci_rxfill()
685 return (serial_port_in(port, SCxSR) & SCxSR_RDxF(port)) != 0; in sci_rxfill()
691 static inline int sci_rxd_in(struct uart_port *port) in sci_rxd_in() argument
693 struct sci_port *s = to_sci_port(port); in sci_rxd_in()
706 static void sci_transmit_chars(struct uart_port *port) in sci_transmit_chars() argument
708 struct circ_buf *xmit = &port->state->xmit; in sci_transmit_chars()
709 unsigned int stopped = uart_tx_stopped(port); in sci_transmit_chars()
714 status = serial_port_in(port, SCxSR); in sci_transmit_chars()
715 if (!(status & SCxSR_TDxE(port))) { in sci_transmit_chars()
716 ctrl = serial_port_in(port, SCSCR); in sci_transmit_chars()
721 serial_port_out(port, SCSCR, ctrl); in sci_transmit_chars()
725 count = sci_txroom(port); in sci_transmit_chars()
730 if (port->x_char) { in sci_transmit_chars()
731 c = port->x_char; in sci_transmit_chars()
732 port->x_char = 0; in sci_transmit_chars()
740 serial_port_out(port, SCxTDR, c); in sci_transmit_chars()
742 port->icount.tx++; in sci_transmit_chars()
745 sci_clear_SCxSR(port, SCxSR_TDxE_CLEAR(port)); in sci_transmit_chars()
748 uart_write_wakeup(port); in sci_transmit_chars()
750 sci_stop_tx(port); in sci_transmit_chars()
757 static void sci_receive_chars(struct uart_port *port) in sci_receive_chars() argument
759 struct sci_port *sci_port = to_sci_port(port); in sci_receive_chars()
760 struct tty_port *tport = &port->state->port; in sci_receive_chars()
765 status = serial_port_in(port, SCxSR); in sci_receive_chars()
766 if (!(status & SCxSR_RDxF(port))) in sci_receive_chars()
771 count = tty_buffer_request_room(tport, sci_rxfill(port)); in sci_receive_chars()
777 if (port->type == PORT_SCI) { in sci_receive_chars()
778 char c = serial_port_in(port, SCxRDR); in sci_receive_chars()
779 if (uart_handle_sysrq_char(port, c) || in sci_receive_chars()
786 char c = serial_port_in(port, SCxRDR); in sci_receive_chars()
788 status = serial_port_in(port, SCxSR); in sci_receive_chars()
793 (status & SCxSR_FER(port))) { in sci_receive_chars()
799 dev_dbg(port->dev, "debounce<%02x>\n", c); in sci_receive_chars()
808 if (uart_handle_sysrq_char(port, c)) { in sci_receive_chars()
814 if (status & SCxSR_FER(port)) { in sci_receive_chars()
816 port->icount.frame++; in sci_receive_chars()
817 dev_notice(port->dev, "frame error\n"); in sci_receive_chars()
818 } else if (status & SCxSR_PER(port)) { in sci_receive_chars()
820 port->icount.parity++; in sci_receive_chars()
821 dev_notice(port->dev, "parity error\n"); in sci_receive_chars()
829 serial_port_in(port, SCxSR); /* dummy read */ in sci_receive_chars()
830 sci_clear_SCxSR(port, SCxSR_RDxF_CLEAR(port)); in sci_receive_chars()
833 port->icount.rx += count; in sci_receive_chars()
841 serial_port_in(port, SCxRDR); in sci_receive_chars()
842 serial_port_in(port, SCxSR); /* dummy read */ in sci_receive_chars()
843 sci_clear_SCxSR(port, SCxSR_RDxF_CLEAR(port)); in sci_receive_chars()
857 static inline void sci_schedule_break_timer(struct sci_port *port) in sci_schedule_break_timer() argument
859 mod_timer(&port->break_timer, jiffies + SCI_BREAK_JIFFIES); in sci_schedule_break_timer()
865 struct sci_port *port = (struct sci_port *)data; in sci_break_timer() local
867 if (sci_rxd_in(&port->port) == 0) { in sci_break_timer()
868 port->break_flag = 1; in sci_break_timer()
869 sci_schedule_break_timer(port); in sci_break_timer()
870 } else if (port->break_flag == 1) { in sci_break_timer()
872 port->break_flag = 2; in sci_break_timer()
873 sci_schedule_break_timer(port); in sci_break_timer()
875 port->break_flag = 0; in sci_break_timer()
878 static int sci_handle_errors(struct uart_port *port) in sci_handle_errors() argument
881 unsigned short status = serial_port_in(port, SCxSR); in sci_handle_errors()
882 struct tty_port *tport = &port->state->port; in sci_handle_errors()
883 struct sci_port *s = to_sci_port(port); in sci_handle_errors()
887 port->icount.overrun++; in sci_handle_errors()
893 dev_notice(port->dev, "overrun error\n"); in sci_handle_errors()
896 if (status & SCxSR_FER(port)) { in sci_handle_errors()
897 if (sci_rxd_in(port) == 0) { in sci_handle_errors()
899 struct sci_port *sci_port = to_sci_port(port); in sci_handle_errors()
902 port->icount.brk++; in sci_handle_errors()
908 if (uart_handle_break(port)) in sci_handle_errors()
911 dev_dbg(port->dev, "BREAK detected\n"); in sci_handle_errors()
919 port->icount.frame++; in sci_handle_errors()
924 dev_notice(port->dev, "frame error\n"); in sci_handle_errors()
928 if (status & SCxSR_PER(port)) { in sci_handle_errors()
930 port->icount.parity++; in sci_handle_errors()
935 dev_notice(port->dev, "parity error\n"); in sci_handle_errors()
944 static int sci_handle_fifo_overrun(struct uart_port *port) in sci_handle_fifo_overrun() argument
946 struct tty_port *tport = &port->state->port; in sci_handle_fifo_overrun()
947 struct sci_port *s = to_sci_port(port); in sci_handle_fifo_overrun()
952 reg = sci_getreg(port, s->overrun_reg); in sci_handle_fifo_overrun()
956 status = serial_port_in(port, s->overrun_reg); in sci_handle_fifo_overrun()
959 serial_port_out(port, s->overrun_reg, status); in sci_handle_fifo_overrun()
961 port->icount.overrun++; in sci_handle_fifo_overrun()
966 dev_dbg(port->dev, "overrun error\n"); in sci_handle_fifo_overrun()
973 static int sci_handle_breaks(struct uart_port *port) in sci_handle_breaks() argument
976 unsigned short status = serial_port_in(port, SCxSR); in sci_handle_breaks()
977 struct tty_port *tport = &port->state->port; in sci_handle_breaks()
978 struct sci_port *s = to_sci_port(port); in sci_handle_breaks()
980 if (uart_handle_break(port)) in sci_handle_breaks()
983 if (!s->break_flag && status & SCxSR_BRK(port)) { in sci_handle_breaks()
989 port->icount.brk++; in sci_handle_breaks()
995 dev_dbg(port->dev, "BREAK detected\n"); in sci_handle_breaks()
1001 copied += sci_handle_fifo_overrun(port); in sci_handle_breaks()
1010 struct uart_port *port = &s->port; in sci_dma_tx_complete() local
1011 struct circ_buf *xmit = &port->state->xmit; in sci_dma_tx_complete()
1014 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); in sci_dma_tx_complete()
1016 spin_lock_irqsave(&port->lock, flags); in sci_dma_tx_complete()
1021 port->icount.tx += s->tx_dma_len; in sci_dma_tx_complete()
1024 uart_write_wakeup(port); in sci_dma_tx_complete()
1031 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { in sci_dma_tx_complete()
1032 u16 ctrl = serial_port_in(port, SCSCR); in sci_dma_tx_complete()
1033 serial_port_out(port, SCSCR, ctrl & ~SCSCR_TIE); in sci_dma_tx_complete()
1037 spin_unlock_irqrestore(&port->lock, flags); in sci_dma_tx_complete()
1043 struct uart_port *port = &s->port; in sci_dma_rx_push() local
1044 struct tty_port *tport = &port->state->port; in sci_dma_rx_push()
1049 dev_warn(port->dev, "Rx overrun: dropping %zu bytes\n", in sci_dma_rx_push()
1051 port->icount.buf_overrun++; in sci_dma_rx_push()
1054 port->icount.rx += copied; in sci_dma_rx_push()
1067 dev_err(s->port.dev, "%s: Rx cookie %d not found!\n", __func__, in sci_dma_rx_find_active()
1075 struct uart_port *port = &s->port; in sci_rx_dma_release() local
1078 spin_lock_irqsave(&port->lock, flags); in sci_rx_dma_release()
1081 spin_unlock_irqrestore(&port->lock, flags); in sci_rx_dma_release()
1087 sci_start_rx(port); in sci_rx_dma_release()
1094 struct uart_port *port = &s->port; in sci_dma_rx_complete() local
1099 dev_dbg(port->dev, "%s(%d) active cookie %d\n", __func__, port->line, in sci_dma_rx_complete()
1102 spin_lock_irqsave(&port->lock, flags); in sci_dma_rx_complete()
1111 tty_flip_buffer_push(&port->state->port); in sci_dma_rx_complete()
1129 dev_dbg(port->dev, "%s: cookie %d #%d, new active cookie %d\n", in sci_dma_rx_complete()
1131 spin_unlock_irqrestore(&port->lock, flags); in sci_dma_rx_complete()
1135 spin_unlock_irqrestore(&port->lock, flags); in sci_dma_rx_complete()
1136 dev_warn(port->dev, "Failed submitting Rx DMA descriptor\n"); in sci_dma_rx_complete()
1143 struct uart_port *port = &s->port; in sci_tx_dma_release() local
1146 spin_lock_irqsave(&port->lock, flags); in sci_tx_dma_release()
1149 spin_unlock_irqrestore(&port->lock, flags); in sci_tx_dma_release()
1155 sci_start_tx(port); in sci_tx_dma_release()
1179 dev_dbg(s->port.dev, "%s(): cookie %d to #%d\n", __func__, in sci_submit_rx()
1194 dev_warn(s->port.dev, "Failed to re-start Rx DMA, using PIO\n"); in sci_submit_rx()
1203 struct uart_port *port = &s->port; in work_fn_tx() local
1204 struct circ_buf *xmit = &port->state->xmit; in work_fn_tx()
1215 spin_lock_irq(&port->lock); in work_fn_tx()
1224 spin_unlock_irq(&port->lock); in work_fn_tx()
1232 spin_unlock_irq(&port->lock); in work_fn_tx()
1233 dev_warn(port->dev, "Failed preparing Tx DMA descriptor\n"); in work_fn_tx()
1246 spin_unlock_irq(&port->lock); in work_fn_tx()
1247 dev_warn(port->dev, "Failed submitting Tx DMA descriptor\n"); in work_fn_tx()
1253 spin_unlock_irq(&port->lock); in work_fn_tx()
1254 dev_dbg(port->dev, "%s: %p: %d...%d, cookie %d\n", in work_fn_tx()
1264 struct uart_port *port = &s->port; in rx_timer_fn() local
1272 spin_lock_irqsave(&port->lock, flags); in rx_timer_fn()
1274 dev_dbg(port->dev, "DMA Rx timed out\n"); in rx_timer_fn()
1278 spin_unlock_irqrestore(&port->lock, flags); in rx_timer_fn()
1284 dev_dbg(port->dev, "Cookie %d #%d has already completed\n", in rx_timer_fn()
1286 spin_unlock_irqrestore(&port->lock, flags); in rx_timer_fn()
1302 spin_unlock_irqrestore(&port->lock, flags); in rx_timer_fn()
1303 dev_dbg(port->dev, "Transaction complete after DMA engine was stopped"); in rx_timer_fn()
1310 dev_dbg(port->dev, "Read %u bytes with cookie %d\n", read, in rx_timer_fn()
1316 tty_flip_buffer_push(&port->state->port); in rx_timer_fn()
1319 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) in rx_timer_fn()
1323 scr = serial_port_in(port, SCSCR); in rx_timer_fn()
1324 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { in rx_timer_fn()
1328 serial_port_out(port, SCSCR, scr | SCSCR_RIE); in rx_timer_fn()
1330 spin_unlock_irqrestore(&port->lock, flags); in rx_timer_fn()
1333 static struct dma_chan *sci_request_dma_chan(struct uart_port *port, in sci_request_dma_chan() argument
1346 (void *)(unsigned long)id, port->dev, in sci_request_dma_chan()
1349 dev_warn(port->dev, in sci_request_dma_chan()
1357 cfg.dst_addr = port->mapbase + in sci_request_dma_chan()
1358 (sci_getreg(port, SCxTDR)->offset << port->regshift); in sci_request_dma_chan()
1361 cfg.src_addr = port->mapbase + in sci_request_dma_chan()
1362 (sci_getreg(port, SCxRDR)->offset << port->regshift); in sci_request_dma_chan()
1368 dev_warn(port->dev, "dmaengine_slave_config failed %d\n", ret); in sci_request_dma_chan()
1376 static void sci_request_dma(struct uart_port *port) in sci_request_dma() argument
1378 struct sci_port *s = to_sci_port(port); in sci_request_dma()
1381 dev_dbg(port->dev, "%s: port %d\n", __func__, port->line); in sci_request_dma()
1383 if (!port->dev->of_node && in sci_request_dma()
1388 chan = sci_request_dma_chan(port, DMA_MEM_TO_DEV, s->cfg->dma_slave_tx); in sci_request_dma()
1389 dev_dbg(port->dev, "%s: TX: got channel %p\n", __func__, chan); in sci_request_dma()
1394 port->state->xmit.buf, in sci_request_dma()
1398 dev_warn(port->dev, "Failed mapping Tx DMA descriptor\n"); in sci_request_dma()
1402 dev_dbg(port->dev, "%s: mapped %lu@%p to %pad\n", in sci_request_dma()
1404 port->state->xmit.buf, &s->tx_dma_addr); in sci_request_dma()
1410 chan = sci_request_dma_chan(port, DMA_DEV_TO_MEM, s->cfg->dma_slave_rx); in sci_request_dma()
1411 dev_dbg(port->dev, "%s: RX: got channel %p\n", __func__, chan); in sci_request_dma()
1419 s->buf_len_rx = 2 * max_t(size_t, 16, port->fifosize); in sci_request_dma()
1423 dev_warn(port->dev, in sci_request_dma()
1444 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) in sci_request_dma()
1449 static void sci_free_dma(struct uart_port *port) in sci_free_dma() argument
1451 struct sci_port *s = to_sci_port(port); in sci_free_dma()
1459 static void sci_flush_buffer(struct uart_port *port) in sci_flush_buffer() argument
1465 to_sci_port(port)->tx_dma_len = 0; in sci_flush_buffer()
1468 static inline void sci_request_dma(struct uart_port *port) in sci_request_dma() argument
1472 static inline void sci_free_dma(struct uart_port *port) in sci_free_dma() argument
1482 struct uart_port *port = ptr; in sci_rx_interrupt() local
1483 struct sci_port *s = to_sci_port(port); in sci_rx_interrupt()
1486 u16 scr = serial_port_in(port, SCSCR); in sci_rx_interrupt()
1487 u16 ssr = serial_port_in(port, SCxSR); in sci_rx_interrupt()
1490 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { in sci_rx_interrupt()
1497 serial_port_out(port, SCSCR, scr); in sci_rx_interrupt()
1499 serial_port_out(port, SCxSR, in sci_rx_interrupt()
1500 ssr & ~(SCIF_DR | SCxSR_RDxF(port))); in sci_rx_interrupt()
1501 dev_dbg(port->dev, "Rx IRQ %lu: setup t-out in %u jiffies\n", in sci_rx_interrupt()
1520 struct uart_port *port = ptr; in sci_tx_interrupt() local
1523 spin_lock_irqsave(&port->lock, flags); in sci_tx_interrupt()
1524 sci_transmit_chars(port); in sci_tx_interrupt()
1525 spin_unlock_irqrestore(&port->lock, flags); in sci_tx_interrupt()
1532 struct uart_port *port = ptr; in sci_er_interrupt() local
1533 struct sci_port *s = to_sci_port(port); in sci_er_interrupt()
1536 if (port->type == PORT_SCI) { in sci_er_interrupt()
1537 if (sci_handle_errors(port)) { in sci_er_interrupt()
1539 serial_port_in(port, SCxSR); in sci_er_interrupt()
1540 sci_clear_SCxSR(port, SCxSR_RDxF_CLEAR(port)); in sci_er_interrupt()
1543 sci_handle_fifo_overrun(port); in sci_er_interrupt()
1548 sci_clear_SCxSR(port, SCxSR_ERROR_CLEAR(port)); in sci_er_interrupt()
1559 struct uart_port *port = ptr; in sci_br_interrupt() local
1562 sci_handle_breaks(port); in sci_br_interrupt()
1563 sci_clear_SCxSR(port, SCxSR_BREAK_CLEAR(port)); in sci_br_interrupt()
1571 struct uart_port *port = ptr; in sci_mpxed_interrupt() local
1572 struct sci_port *s = to_sci_port(port); in sci_mpxed_interrupt()
1575 ssr_status = serial_port_in(port, SCxSR); in sci_mpxed_interrupt()
1576 scr_status = serial_port_in(port, SCSCR); in sci_mpxed_interrupt()
1580 if (sci_getreg(port, s->overrun_reg)->size) in sci_mpxed_interrupt()
1581 orer_status = serial_port_in(port, s->overrun_reg); in sci_mpxed_interrupt()
1584 err_enabled = scr_status & port_rx_irq_mask(port); in sci_mpxed_interrupt()
1587 if ((ssr_status & SCxSR_TDxE(port)) && (scr_status & SCSCR_TIE) && in sci_mpxed_interrupt()
1595 if (((ssr_status & SCxSR_RDxF(port)) || s->chan_rx) && in sci_mpxed_interrupt()
1600 if ((ssr_status & SCxSR_ERRORS(port)) && err_enabled) in sci_mpxed_interrupt()
1604 if ((ssr_status & SCxSR_BRK(port)) && err_enabled) in sci_mpxed_interrupt()
1609 sci_handle_fifo_overrun(port); in sci_mpxed_interrupt()
1652 static int sci_request_irq(struct sci_port *port) in sci_request_irq() argument
1654 struct uart_port *up = &port->port; in sci_request_irq()
1661 if (SCIx_IRQ_IS_MUXED(port)) { in sci_request_irq()
1665 irq = port->irqs[i]; in sci_request_irq()
1676 port->irqstr[j] = kasprintf(GFP_KERNEL, "%s:%s", in sci_request_irq()
1678 if (!port->irqstr[j]) in sci_request_irq()
1682 port->irqstr[j], port); in sci_request_irq()
1693 free_irq(port->irqs[i], port); in sci_request_irq()
1697 kfree(port->irqstr[j]); in sci_request_irq()
1702 static void sci_free_irq(struct sci_port *port) in sci_free_irq() argument
1711 int irq = port->irqs[i]; in sci_free_irq()
1720 free_irq(port->irqs[i], port); in sci_free_irq()
1721 kfree(port->irqstr[i]); in sci_free_irq()
1723 if (SCIx_IRQ_IS_MUXED(port)) { in sci_free_irq()
1730 static unsigned int sci_tx_empty(struct uart_port *port) in sci_tx_empty() argument
1732 unsigned short status = serial_port_in(port, SCxSR); in sci_tx_empty()
1733 unsigned short in_tx_fifo = sci_txfill(port); in sci_tx_empty()
1735 return (status & SCxSR_TEND(port)) && !in_tx_fifo ? TIOCSER_TEMT : 0; in sci_tx_empty()
1750 static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl) in sci_set_mctrl() argument
1758 reg = sci_getreg(port, SCFCR); in sci_set_mctrl()
1760 serial_port_out(port, SCFCR, in sci_set_mctrl()
1761 serial_port_in(port, SCFCR) | in sci_set_mctrl()
1766 static unsigned int sci_get_mctrl(struct uart_port *port) in sci_get_mctrl() argument
1775 static void sci_break_ctl(struct uart_port *port, int break_state) in sci_break_ctl() argument
1777 struct sci_port *s = to_sci_port(port); in sci_break_ctl()
1790 scsptr = serial_port_in(port, SCSPTR); in sci_break_ctl()
1791 scscr = serial_port_in(port, SCSCR); in sci_break_ctl()
1801 serial_port_out(port, SCSPTR, scsptr); in sci_break_ctl()
1802 serial_port_out(port, SCSCR, scscr); in sci_break_ctl()
1805 static int sci_startup(struct uart_port *port) in sci_startup() argument
1807 struct sci_port *s = to_sci_port(port); in sci_startup()
1811 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); in sci_startup()
1813 sci_request_dma(port); in sci_startup()
1817 sci_free_dma(port); in sci_startup()
1821 spin_lock_irqsave(&port->lock, flags); in sci_startup()
1822 sci_start_tx(port); in sci_startup()
1823 sci_start_rx(port); in sci_startup()
1824 spin_unlock_irqrestore(&port->lock, flags); in sci_startup()
1829 static void sci_shutdown(struct uart_port *port) in sci_shutdown() argument
1831 struct sci_port *s = to_sci_port(port); in sci_shutdown()
1834 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); in sci_shutdown()
1836 spin_lock_irqsave(&port->lock, flags); in sci_shutdown()
1837 sci_stop_rx(port); in sci_shutdown()
1838 sci_stop_tx(port); in sci_shutdown()
1839 spin_unlock_irqrestore(&port->lock, flags); in sci_shutdown()
1843 dev_dbg(port->dev, "%s(%d) deleting rx_timer\n", __func__, in sci_shutdown()
1844 port->line); in sci_shutdown()
1850 sci_free_dma(port); in sci_shutdown()
1939 static void sci_reset(struct uart_port *port) in sci_reset() argument
1945 status = serial_port_in(port, SCxSR); in sci_reset()
1946 } while (!(status & SCxSR_TEND(port))); in sci_reset()
1948 serial_port_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ in sci_reset()
1950 reg = sci_getreg(port, SCFCR); in sci_reset()
1952 serial_port_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST); in sci_reset()
1955 static void sci_set_termios(struct uart_port *port, struct ktermios *termios, in sci_set_termios() argument
1958 struct sci_port *s = to_sci_port(port); in sci_set_termios()
1981 max_baud = port->uartclk ? port->uartclk / 16 : 115200; in sci_set_termios()
1983 baud = uart_get_baud_rate(port, termios, old, 0, max_baud); in sci_set_termios()
1984 if (likely(baud && port->uartclk)) { in sci_set_termios()
1987 sci_baud_calc_hscif(baud, port->uartclk, &t, &srr, in sci_set_termios()
1990 t = sci_scbrr_calc(s, baud, port->uartclk); in sci_set_termios()
1998 sci_reset(port); in sci_set_termios()
2000 smr_val |= serial_port_in(port, SCSMR) & SCSMR_CKS; in sci_set_termios()
2002 uart_update_timeout(port, termios->c_cflag, baud); in sci_set_termios()
2004 dev_dbg(port->dev, "%s: SMR %x, cks %x, t %x, SCSCR %x\n", in sci_set_termios()
2008 serial_port_out(port, SCSMR, (smr_val & ~SCSMR_CKS) | cks); in sci_set_termios()
2009 serial_port_out(port, SCBRR, t); in sci_set_termios()
2010 reg = sci_getreg(port, HSSRR); in sci_set_termios()
2012 serial_port_out(port, HSSRR, srr | HSCIF_SRE); in sci_set_termios()
2015 serial_port_out(port, SCSMR, smr_val); in sci_set_termios()
2017 sci_init_pins(port, termios->c_cflag); in sci_set_termios()
2019 reg = sci_getreg(port, SCFCR); in sci_set_termios()
2021 unsigned short ctrl = serial_port_in(port, SCFCR); in sci_set_termios()
2037 serial_port_out(port, SCFCR, ctrl); in sci_set_termios()
2040 serial_port_out(port, SCSCR, s->cfg->scscr); in sci_set_termios()
2078 dev_dbg(port->dev, "DMA Rx t-out %ums, tty t-out %u jiffies\n", in sci_set_termios()
2079 s->rx_timeout * 1000 / HZ, port->timeout); in sci_set_termios()
2086 sci_start_rx(port); in sci_set_termios()
2091 static void sci_pm(struct uart_port *port, unsigned int state, in sci_pm() argument
2094 struct sci_port *sci_port = to_sci_port(port); in sci_pm()
2106 static const char *sci_type(struct uart_port *port) in sci_type() argument
2108 switch (port->type) { in sci_type()
2126 static int sci_remap_port(struct uart_port *port) in sci_remap_port() argument
2128 struct sci_port *sport = to_sci_port(port); in sci_remap_port()
2133 if (port->membase) in sci_remap_port()
2136 if (port->flags & UPF_IOREMAP) { in sci_remap_port()
2137 port->membase = ioremap_nocache(port->mapbase, sport->reg_size); in sci_remap_port()
2138 if (unlikely(!port->membase)) { in sci_remap_port()
2139 dev_err(port->dev, "can't remap port#%d\n", port->line); in sci_remap_port()
2148 port->membase = (void __iomem *)(uintptr_t)port->mapbase; in sci_remap_port()
2154 static void sci_release_port(struct uart_port *port) in sci_release_port() argument
2156 struct sci_port *sport = to_sci_port(port); in sci_release_port()
2158 if (port->flags & UPF_IOREMAP) { in sci_release_port()
2159 iounmap(port->membase); in sci_release_port()
2160 port->membase = NULL; in sci_release_port()
2163 release_mem_region(port->mapbase, sport->reg_size); in sci_release_port()
2166 static int sci_request_port(struct uart_port *port) in sci_request_port() argument
2169 struct sci_port *sport = to_sci_port(port); in sci_request_port()
2172 res = request_mem_region(port->mapbase, sport->reg_size, in sci_request_port()
2173 dev_name(port->dev)); in sci_request_port()
2175 dev_err(port->dev, "request_mem_region failed."); in sci_request_port()
2179 ret = sci_remap_port(port); in sci_request_port()
2188 static void sci_config_port(struct uart_port *port, int flags) in sci_config_port() argument
2191 struct sci_port *sport = to_sci_port(port); in sci_config_port()
2193 port->type = sport->cfg->type; in sci_config_port()
2194 sci_request_port(port); in sci_config_port()
2198 static int sci_verify_port(struct uart_port *port, struct serial_struct *ser) in sci_verify_port() argument
2235 struct uart_port *port = &sci_port->port; in sci_init_single() local
2242 port->ops = &sci_uart_ops; in sci_init_single()
2243 port->iotype = UPIO_MEM; in sci_init_single()
2244 port->line = index; in sci_init_single()
2250 port->mapbase = res->start; in sci_init_single()
2278 port->fifosize = 256; in sci_init_single()
2284 port->fifosize = 128; in sci_init_single()
2290 port->fifosize = 64; in sci_init_single()
2296 port->fifosize = 16; in sci_init_single()
2308 port->fifosize = 1; in sci_init_single()
2340 port->dev = &dev->dev; in sci_init_single()
2369 port->type = p->type; in sci_init_single()
2370 port->flags = UPF_FIXED_PORT | p->flags; in sci_init_single()
2371 port->regshift = p->regshift; in sci_init_single()
2380 port->irq = sci_port->irqs[SCIx_RXI_IRQ]; in sci_init_single()
2381 port->irqflags = 0; in sci_init_single()
2383 port->serial_in = sci_serial_in; in sci_init_single()
2384 port->serial_out = sci_serial_out; in sci_init_single()
2387 dev_dbg(port->dev, "DMA tx %d, rx %d\n", in sci_init_single()
2393 static void sci_cleanup_single(struct sci_port *port) in sci_cleanup_single() argument
2395 clk_put(port->iclk); in sci_cleanup_single()
2396 clk_put(port->fclk); in sci_cleanup_single()
2398 pm_runtime_disable(port->port.dev); in sci_cleanup_single()
2402 static void serial_console_putchar(struct uart_port *port, int ch) in serial_console_putchar() argument
2404 sci_poll_put_char(port, ch); in serial_console_putchar()
2415 struct uart_port *port = &sci_port->port; in serial_console_write() local
2420 if (port->sysrq) in serial_console_write()
2423 locked = spin_trylock_irqsave(&port->lock, flags); in serial_console_write()
2425 spin_lock_irqsave(&port->lock, flags); in serial_console_write()
2428 ctrl = serial_port_in(port, SCSCR); in serial_console_write()
2429 serial_port_out(port, SCSCR, sci_port->cfg->scscr); in serial_console_write()
2431 uart_console_write(port, s, count, serial_console_putchar); in serial_console_write()
2434 bits = SCxSR_TDxE(port) | SCxSR_TEND(port); in serial_console_write()
2435 while ((serial_port_in(port, SCxSR) & bits) != bits) in serial_console_write()
2439 serial_port_out(port, SCSCR, ctrl); in serial_console_write()
2442 spin_unlock_irqrestore(&port->lock, flags); in serial_console_write()
2448 struct uart_port *port; in serial_console_setup() local
2462 port = &sci_port->port; in serial_console_setup()
2467 if (!port->ops) in serial_console_setup()
2470 ret = sci_remap_port(port); in serial_console_setup()
2477 return uart_set_options(port, co, baud, parity, bits, flow); in serial_console_setup()
2545 struct sci_port *port = platform_get_drvdata(dev); in sci_remove() local
2547 uart_remove_one_port(&sci_uart_driver, &port->port); in sci_remove()
2549 sci_cleanup_single(port); in sci_remove()
2654 ret = uart_add_one_port(&sci_uart_driver, &sciport->port); in sci_probe_single()
2711 uart_suspend_port(&sci_uart_driver, &sport->port); in sci_suspend()
2721 uart_resume_port(&sci_uart_driver, &sport->port); in sci_resume()