Lines Matching refs:port
73 #define SCIx_IRQ_IS_MUXED(port) \ argument
74 ((port)->irqs[SCIx_ERI_IRQ] == \
75 (port)->irqs[SCIx_RXI_IRQ]) || \
76 ((port)->irqs[SCIx_ERI_IRQ] && \
77 ((port)->irqs[SCIx_RXI_IRQ] < 0))
80 struct uart_port port; member
126 static void sci_start_tx(struct uart_port *port);
127 static void sci_stop_tx(struct uart_port *port);
128 static void sci_start_rx(struct uart_port *port);
138 return container_of(uart, struct sci_port, port); in to_sci_port()
440 if (!sci_port->port.dev) in sci_port_enable()
443 pm_runtime_get_sync(sci_port->port.dev); in sci_port_enable()
446 sci_port->port.uartclk = clk_get_rate(sci_port->iclk); in sci_port_enable()
452 if (!sci_port->port.dev) in sci_port_disable()
466 pm_runtime_put_sync(sci_port->port.dev); in sci_port_disable()
472 static int sci_poll_get_char(struct uart_port *port) in sci_poll_get_char() argument
478 status = serial_port_in(port, SCxSR); in sci_poll_get_char()
479 if (status & SCxSR_ERRORS(port)) { in sci_poll_get_char()
480 serial_port_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); in sci_poll_get_char()
486 if (!(status & SCxSR_RDxF(port))) in sci_poll_get_char()
489 c = serial_port_in(port, SCxRDR); in sci_poll_get_char()
492 serial_port_in(port, SCxSR); in sci_poll_get_char()
493 serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); in sci_poll_get_char()
499 static void sci_poll_put_char(struct uart_port *port, unsigned char c) in sci_poll_put_char() argument
504 status = serial_port_in(port, SCxSR); in sci_poll_put_char()
505 } while (!(status & SCxSR_TDxE(port))); in sci_poll_put_char()
507 serial_port_out(port, SCxTDR, c); in sci_poll_put_char()
508 serial_port_out(port, SCxSR, SCxSR_TDxE_CLEAR(port) & ~SCxSR_TEND(port)); in sci_poll_put_char()
512 static void sci_init_pins(struct uart_port *port, unsigned int cflag) in sci_init_pins() argument
514 struct sci_port *s = to_sci_port(port); in sci_init_pins()
521 s->cfg->ops->init_pins(port, cflag); in sci_init_pins()
536 status = serial_port_in(port, SCSPTR); in sci_init_pins()
539 serial_port_out(port, SCSPTR, status); /* Set RTS = 1 */ in sci_init_pins()
543 static int sci_txfill(struct uart_port *port) in sci_txfill() argument
547 reg = sci_getreg(port, SCTFDR); in sci_txfill()
549 return serial_port_in(port, SCTFDR) & ((port->fifosize << 1) - 1); in sci_txfill()
551 reg = sci_getreg(port, SCFDR); in sci_txfill()
553 return serial_port_in(port, SCFDR) >> 8; in sci_txfill()
555 return !(serial_port_in(port, SCxSR) & SCI_TDRE); in sci_txfill()
558 static int sci_txroom(struct uart_port *port) in sci_txroom() argument
560 return port->fifosize - sci_txfill(port); in sci_txroom()
563 static int sci_rxfill(struct uart_port *port) in sci_rxfill() argument
567 reg = sci_getreg(port, SCRFDR); in sci_rxfill()
569 return serial_port_in(port, SCRFDR) & ((port->fifosize << 1) - 1); in sci_rxfill()
571 reg = sci_getreg(port, SCFDR); in sci_rxfill()
573 return serial_port_in(port, SCFDR) & ((port->fifosize << 1) - 1); in sci_rxfill()
575 return (serial_port_in(port, SCxSR) & SCxSR_RDxF(port)) != 0; in sci_rxfill()
581 static inline int sci_rxd_in(struct uart_port *port) in sci_rxd_in() argument
583 struct sci_port *s = to_sci_port(port); in sci_rxd_in()
596 static void sci_transmit_chars(struct uart_port *port) in sci_transmit_chars() argument
598 struct circ_buf *xmit = &port->state->xmit; in sci_transmit_chars()
599 unsigned int stopped = uart_tx_stopped(port); in sci_transmit_chars()
604 status = serial_port_in(port, SCxSR); in sci_transmit_chars()
605 if (!(status & SCxSR_TDxE(port))) { in sci_transmit_chars()
606 ctrl = serial_port_in(port, SCSCR); in sci_transmit_chars()
611 serial_port_out(port, SCSCR, ctrl); in sci_transmit_chars()
615 count = sci_txroom(port); in sci_transmit_chars()
620 if (port->x_char) { in sci_transmit_chars()
621 c = port->x_char; in sci_transmit_chars()
622 port->x_char = 0; in sci_transmit_chars()
630 serial_port_out(port, SCxTDR, c); in sci_transmit_chars()
632 port->icount.tx++; in sci_transmit_chars()
635 serial_port_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); in sci_transmit_chars()
638 uart_write_wakeup(port); in sci_transmit_chars()
640 sci_stop_tx(port); in sci_transmit_chars()
642 ctrl = serial_port_in(port, SCSCR); in sci_transmit_chars()
644 if (port->type != PORT_SCI) { in sci_transmit_chars()
645 serial_port_in(port, SCxSR); /* Dummy read */ in sci_transmit_chars()
646 serial_port_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); in sci_transmit_chars()
650 serial_port_out(port, SCSCR, ctrl); in sci_transmit_chars()
657 static void sci_receive_chars(struct uart_port *port) in sci_receive_chars() argument
659 struct sci_port *sci_port = to_sci_port(port); in sci_receive_chars()
660 struct tty_port *tport = &port->state->port; in sci_receive_chars()
665 status = serial_port_in(port, SCxSR); in sci_receive_chars()
666 if (!(status & SCxSR_RDxF(port))) in sci_receive_chars()
671 count = tty_buffer_request_room(tport, sci_rxfill(port)); in sci_receive_chars()
677 if (port->type == PORT_SCI) { in sci_receive_chars()
678 char c = serial_port_in(port, SCxRDR); in sci_receive_chars()
679 if (uart_handle_sysrq_char(port, c) || in sci_receive_chars()
686 char c = serial_port_in(port, SCxRDR); in sci_receive_chars()
688 status = serial_port_in(port, SCxSR); in sci_receive_chars()
693 (status & SCxSR_FER(port))) { in sci_receive_chars()
699 dev_dbg(port->dev, "debounce<%02x>\n", c); in sci_receive_chars()
708 if (uart_handle_sysrq_char(port, c)) { in sci_receive_chars()
714 if (status & SCxSR_FER(port)) { in sci_receive_chars()
716 port->icount.frame++; in sci_receive_chars()
717 dev_notice(port->dev, "frame error\n"); in sci_receive_chars()
718 } else if (status & SCxSR_PER(port)) { in sci_receive_chars()
720 port->icount.parity++; in sci_receive_chars()
721 dev_notice(port->dev, "parity error\n"); in sci_receive_chars()
729 serial_port_in(port, SCxSR); /* dummy read */ in sci_receive_chars()
730 serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); in sci_receive_chars()
733 port->icount.rx += count; in sci_receive_chars()
740 serial_port_in(port, SCxSR); /* dummy read */ in sci_receive_chars()
741 serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); in sci_receive_chars()
755 static inline void sci_schedule_break_timer(struct sci_port *port) in sci_schedule_break_timer() argument
757 mod_timer(&port->break_timer, jiffies + SCI_BREAK_JIFFIES); in sci_schedule_break_timer()
763 struct sci_port *port = (struct sci_port *)data; in sci_break_timer() local
765 if (sci_rxd_in(&port->port) == 0) { in sci_break_timer()
766 port->break_flag = 1; in sci_break_timer()
767 sci_schedule_break_timer(port); in sci_break_timer()
768 } else if (port->break_flag == 1) { in sci_break_timer()
770 port->break_flag = 2; in sci_break_timer()
771 sci_schedule_break_timer(port); in sci_break_timer()
773 port->break_flag = 0; in sci_break_timer()
776 static int sci_handle_errors(struct uart_port *port) in sci_handle_errors() argument
779 unsigned short status = serial_port_in(port, SCxSR); in sci_handle_errors()
780 struct tty_port *tport = &port->state->port; in sci_handle_errors()
781 struct sci_port *s = to_sci_port(port); in sci_handle_errors()
785 port->icount.overrun++; in sci_handle_errors()
791 dev_notice(port->dev, "overrun error\n"); in sci_handle_errors()
794 if (status & SCxSR_FER(port)) { in sci_handle_errors()
795 if (sci_rxd_in(port) == 0) { in sci_handle_errors()
797 struct sci_port *sci_port = to_sci_port(port); in sci_handle_errors()
800 port->icount.brk++; in sci_handle_errors()
806 if (uart_handle_break(port)) in sci_handle_errors()
809 dev_dbg(port->dev, "BREAK detected\n"); in sci_handle_errors()
817 port->icount.frame++; in sci_handle_errors()
822 dev_notice(port->dev, "frame error\n"); in sci_handle_errors()
826 if (status & SCxSR_PER(port)) { in sci_handle_errors()
828 port->icount.parity++; in sci_handle_errors()
833 dev_notice(port->dev, "parity error\n"); in sci_handle_errors()
842 static int sci_handle_fifo_overrun(struct uart_port *port) in sci_handle_fifo_overrun() argument
844 struct tty_port *tport = &port->state->port; in sci_handle_fifo_overrun()
845 struct sci_port *s = to_sci_port(port); in sci_handle_fifo_overrun()
850 switch (port->type) { in sci_handle_fifo_overrun()
863 reg = sci_getreg(port, offset); in sci_handle_fifo_overrun()
867 status = serial_port_in(port, offset); in sci_handle_fifo_overrun()
872 serial_port_out(port, offset, status); in sci_handle_fifo_overrun()
874 port->icount.overrun++; in sci_handle_fifo_overrun()
879 dev_dbg(port->dev, "overrun error\n"); in sci_handle_fifo_overrun()
886 static int sci_handle_breaks(struct uart_port *port) in sci_handle_breaks() argument
889 unsigned short status = serial_port_in(port, SCxSR); in sci_handle_breaks()
890 struct tty_port *tport = &port->state->port; in sci_handle_breaks()
891 struct sci_port *s = to_sci_port(port); in sci_handle_breaks()
893 if (uart_handle_break(port)) in sci_handle_breaks()
896 if (!s->break_flag && status & SCxSR_BRK(port)) { in sci_handle_breaks()
902 port->icount.brk++; in sci_handle_breaks()
908 dev_dbg(port->dev, "BREAK detected\n"); in sci_handle_breaks()
914 copied += sci_handle_fifo_overrun(port); in sci_handle_breaks()
922 struct uart_port *port = ptr; in sci_rx_interrupt() local
923 struct sci_port *s = to_sci_port(port); in sci_rx_interrupt()
926 u16 scr = serial_port_in(port, SCSCR); in sci_rx_interrupt()
927 u16 ssr = serial_port_in(port, SCxSR); in sci_rx_interrupt()
930 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { in sci_rx_interrupt()
936 serial_port_out(port, SCSCR, scr); in sci_rx_interrupt()
938 serial_port_out(port, SCxSR, ssr & ~(1 | SCxSR_RDxF(port))); in sci_rx_interrupt()
939 dev_dbg(port->dev, "Rx IRQ %lu: setup t-out in %u jiffies\n", in sci_rx_interrupt()
958 struct uart_port *port = ptr; in sci_tx_interrupt() local
961 spin_lock_irqsave(&port->lock, flags); in sci_tx_interrupt()
962 sci_transmit_chars(port); in sci_tx_interrupt()
963 spin_unlock_irqrestore(&port->lock, flags); in sci_tx_interrupt()
970 struct uart_port *port = ptr; in sci_er_interrupt() local
973 if (port->type == PORT_SCI) { in sci_er_interrupt()
974 if (sci_handle_errors(port)) { in sci_er_interrupt()
976 serial_port_in(port, SCxSR); in sci_er_interrupt()
977 serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); in sci_er_interrupt()
980 sci_handle_fifo_overrun(port); in sci_er_interrupt()
984 serial_port_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); in sci_er_interrupt()
994 struct uart_port *port = ptr; in sci_br_interrupt() local
997 sci_handle_breaks(port); in sci_br_interrupt()
998 serial_port_out(port, SCxSR, SCxSR_BREAK_CLEAR(port)); in sci_br_interrupt()
1003 static inline unsigned long port_rx_irq_mask(struct uart_port *port) in port_rx_irq_mask() argument
1012 return SCSCR_RIE | (to_sci_port(port)->cfg->scscr & SCSCR_REIE); in port_rx_irq_mask()
1018 struct uart_port *port = ptr; in sci_mpxed_interrupt() local
1019 struct sci_port *s = to_sci_port(port); in sci_mpxed_interrupt()
1022 ssr_status = serial_port_in(port, SCxSR); in sci_mpxed_interrupt()
1023 scr_status = serial_port_in(port, SCSCR); in sci_mpxed_interrupt()
1024 switch (port->type) { in sci_mpxed_interrupt()
1027 orer_status = serial_port_in(port, SCLSR); in sci_mpxed_interrupt()
1035 err_enabled = scr_status & port_rx_irq_mask(port); in sci_mpxed_interrupt()
1038 if ((ssr_status & SCxSR_TDxE(port)) && (scr_status & SCSCR_TIE) && in sci_mpxed_interrupt()
1046 if (((ssr_status & SCxSR_RDxF(port)) || s->chan_rx) && in sci_mpxed_interrupt()
1048 if (port->type == PORT_SCIF || port->type == PORT_HSCIF) in sci_mpxed_interrupt()
1049 sci_handle_fifo_overrun(port); in sci_mpxed_interrupt()
1054 if ((ssr_status & SCxSR_ERRORS(port)) && err_enabled) in sci_mpxed_interrupt()
1058 if ((ssr_status & SCxSR_BRK(port)) && err_enabled) in sci_mpxed_interrupt()
1063 sci_handle_fifo_overrun(port); in sci_mpxed_interrupt()
1081 struct uart_port *port = &sci_port->port; in sci_notifier() local
1083 spin_lock_irqsave(&port->lock, flags); in sci_notifier()
1084 port->uartclk = clk_get_rate(sci_port->iclk); in sci_notifier()
1085 spin_unlock_irqrestore(&port->lock, flags); in sci_notifier()
1127 static int sci_request_irq(struct sci_port *port) in sci_request_irq() argument
1129 struct uart_port *up = &port->port; in sci_request_irq()
1136 if (SCIx_IRQ_IS_MUXED(port)) { in sci_request_irq()
1140 irq = port->irqs[i]; in sci_request_irq()
1151 port->irqstr[j] = kasprintf(GFP_KERNEL, "%s:%s", in sci_request_irq()
1153 if (!port->irqstr[j]) { in sci_request_irq()
1160 port->irqstr[j], port); in sci_request_irq()
1171 free_irq(port->irqs[i], port); in sci_request_irq()
1175 kfree(port->irqstr[j]); in sci_request_irq()
1180 static void sci_free_irq(struct sci_port *port) in sci_free_irq() argument
1189 int irq = port->irqs[i]; in sci_free_irq()
1198 free_irq(port->irqs[i], port); in sci_free_irq()
1199 kfree(port->irqstr[i]); in sci_free_irq()
1201 if (SCIx_IRQ_IS_MUXED(port)) { in sci_free_irq()
1208 static unsigned int sci_tx_empty(struct uart_port *port) in sci_tx_empty() argument
1210 unsigned short status = serial_port_in(port, SCxSR); in sci_tx_empty()
1211 unsigned short in_tx_fifo = sci_txfill(port); in sci_tx_empty()
1213 return (status & SCxSR_TEND(port)) && !in_tx_fifo ? TIOCSER_TEMT : 0; in sci_tx_empty()
1228 static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl) in sci_set_mctrl() argument
1236 reg = sci_getreg(port, SCFCR); in sci_set_mctrl()
1238 serial_port_out(port, SCFCR, in sci_set_mctrl()
1239 serial_port_in(port, SCFCR) | in sci_set_mctrl()
1244 static unsigned int sci_get_mctrl(struct uart_port *port) in sci_get_mctrl() argument
1257 struct uart_port *port = &s->port; in sci_dma_tx_complete() local
1258 struct circ_buf *xmit = &port->state->xmit; in sci_dma_tx_complete()
1261 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); in sci_dma_tx_complete()
1263 spin_lock_irqsave(&port->lock, flags); in sci_dma_tx_complete()
1268 port->icount.tx += sg_dma_len(&s->sg_tx); in sci_dma_tx_complete()
1274 uart_write_wakeup(port); in sci_dma_tx_complete()
1281 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { in sci_dma_tx_complete()
1282 u16 ctrl = serial_port_in(port, SCSCR); in sci_dma_tx_complete()
1283 serial_port_out(port, SCSCR, ctrl & ~SCSCR_TIE); in sci_dma_tx_complete()
1287 spin_unlock_irqrestore(&port->lock, flags); in sci_dma_tx_complete()
1293 struct uart_port *port = &s->port; in sci_dma_rx_push() local
1294 struct tty_port *tport = &port->state->port; in sci_dma_rx_push()
1304 dev_err(port->dev, "cookie %d not found!\n", s->active_rx); in sci_dma_rx_push()
1309 dev_warn(port->dev, "Rx overrun: dropping %zu bytes\n", in sci_dma_rx_push()
1318 port->icount.rx += room; in sci_dma_rx_push()
1326 struct uart_port *port = &s->port; in sci_dma_rx_complete() local
1330 dev_dbg(port->dev, "%s(%d) active #%d\n", in sci_dma_rx_complete()
1331 __func__, port->line, s->active_rx); in sci_dma_rx_complete()
1333 spin_lock_irqsave(&port->lock, flags); in sci_dma_rx_complete()
1339 spin_unlock_irqrestore(&port->lock, flags); in sci_dma_rx_complete()
1342 tty_flip_buffer_push(&port->state->port); in sci_dma_rx_complete()
1350 struct uart_port *port = &s->port; in sci_rx_dma_release() local
1356 dma_free_coherent(port->dev, s->buf_len_rx * 2, in sci_rx_dma_release()
1359 sci_start_rx(port); in sci_rx_dma_release()
1365 struct uart_port *port = &s->port; in sci_tx_dma_release() local
1371 sci_start_tx(port); in sci_tx_dma_release()
1402 dev_warn(s->port.dev, in sci_submit_rx()
1407 dev_dbg(s->port.dev, "%s(): cookie %d to #%d\n", in sci_submit_rx()
1419 struct uart_port *port = &s->port; in work_fn_rx() local
1428 dev_err(port->dev, "cookie %d not found!\n", s->active_rx); in work_fn_rx()
1443 dev_dbg(port->dev, "Read %zu bytes with cookie %d\n", in work_fn_rx()
1446 spin_lock_irqsave(&port->lock, flags); in work_fn_rx()
1448 spin_unlock_irqrestore(&port->lock, flags); in work_fn_rx()
1451 tty_flip_buffer_push(&port->state->port); in work_fn_rx()
1460 dev_warn(port->dev, "Failed submitting Rx DMA descriptor\n"); in work_fn_rx()
1467 dev_dbg(port->dev, "%s: cookie %d #%d, new active #%d\n", in work_fn_rx()
1476 struct uart_port *port = &s->port; in work_fn_tx() local
1477 struct circ_buf *xmit = &port->state->xmit; in work_fn_tx()
1487 spin_lock_irq(&port->lock); in work_fn_tx()
1493 spin_unlock_irq(&port->lock); in work_fn_tx()
1506 dma_sync_sg_for_device(port->dev, sg, 1, DMA_TO_DEVICE); in work_fn_tx()
1508 spin_lock_irq(&port->lock); in work_fn_tx()
1512 spin_unlock_irq(&port->lock); in work_fn_tx()
1515 dev_warn(port->dev, "Failed submitting Tx DMA descriptor\n"); in work_fn_tx()
1521 dev_dbg(port->dev, "%s: %p: %d...%d, cookie %d\n", in work_fn_tx()
1528 static void sci_start_tx(struct uart_port *port) in sci_start_tx() argument
1530 struct sci_port *s = to_sci_port(port); in sci_start_tx()
1534 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { in sci_start_tx()
1535 u16 new, scr = serial_port_in(port, SCSCR); in sci_start_tx()
1541 serial_port_out(port, SCSCR, new); in sci_start_tx()
1544 if (s->chan_tx && !uart_circ_empty(&s->port.state->xmit) && in sci_start_tx()
1551 if (!s->chan_tx || port->type == PORT_SCIFA || port->type == PORT_SCIFB) { in sci_start_tx()
1553 ctrl = serial_port_in(port, SCSCR); in sci_start_tx()
1554 serial_port_out(port, SCSCR, ctrl | SCSCR_TIE); in sci_start_tx()
1558 static void sci_stop_tx(struct uart_port *port) in sci_stop_tx() argument
1563 ctrl = serial_port_in(port, SCSCR); in sci_stop_tx()
1565 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) in sci_stop_tx()
1570 serial_port_out(port, SCSCR, ctrl); in sci_stop_tx()
1573 static void sci_start_rx(struct uart_port *port) in sci_start_rx() argument
1577 ctrl = serial_port_in(port, SCSCR) | port_rx_irq_mask(port); in sci_start_rx()
1579 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) in sci_start_rx()
1582 serial_port_out(port, SCSCR, ctrl); in sci_start_rx()
1585 static void sci_stop_rx(struct uart_port *port) in sci_stop_rx() argument
1589 ctrl = serial_port_in(port, SCSCR); in sci_stop_rx()
1591 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) in sci_stop_rx()
1594 ctrl &= ~port_rx_irq_mask(port); in sci_stop_rx()
1596 serial_port_out(port, SCSCR, ctrl); in sci_stop_rx()
1599 static void sci_break_ctl(struct uart_port *port, int break_state) in sci_break_ctl() argument
1601 struct sci_port *s = to_sci_port(port); in sci_break_ctl()
1614 scsptr = serial_port_in(port, SCSPTR); in sci_break_ctl()
1615 scscr = serial_port_in(port, SCSCR); in sci_break_ctl()
1625 serial_port_out(port, SCSPTR, scsptr); in sci_break_ctl()
1626 serial_port_out(port, SCSCR, scscr); in sci_break_ctl()
1644 struct uart_port *port = &s->port; in rx_timer_fn() local
1645 u16 scr = serial_port_in(port, SCSCR); in rx_timer_fn()
1647 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { in rx_timer_fn()
1651 serial_port_out(port, SCSCR, scr | SCSCR_RIE); in rx_timer_fn()
1652 dev_dbg(port->dev, "DMA Rx timed out\n"); in rx_timer_fn()
1656 static void sci_request_dma(struct uart_port *port) in sci_request_dma() argument
1658 struct sci_port *s = to_sci_port(port); in sci_request_dma()
1664 dev_dbg(port->dev, "%s: port %d\n", __func__, port->line); in sci_request_dma()
1679 dev_dbg(port->dev, "%s: TX: got channel %p\n", __func__, chan); in sci_request_dma()
1684 BUG_ON((uintptr_t)port->state->xmit.buf & ~PAGE_MASK); in sci_request_dma()
1685 sg_set_page(&s->sg_tx, virt_to_page(port->state->xmit.buf), in sci_request_dma()
1687 (uintptr_t)port->state->xmit.buf & ~PAGE_MASK); in sci_request_dma()
1688 nent = dma_map_sg(port->dev, &s->sg_tx, 1, DMA_TO_DEVICE); in sci_request_dma()
1692 dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", in sci_request_dma()
1694 sg_dma_len(&s->sg_tx), port->state->xmit.buf, in sci_request_dma()
1708 dev_dbg(port->dev, "%s: RX: got channel %p\n", __func__, chan); in sci_request_dma()
1716 s->buf_len_rx = 2 * max(16, (int)port->fifosize); in sci_request_dma()
1717 buf[0] = dma_alloc_coherent(port->dev, s->buf_len_rx * 2, in sci_request_dma()
1721 dev_warn(port->dev, in sci_request_dma()
1746 static void sci_free_dma(struct uart_port *port) in sci_free_dma() argument
1748 struct sci_port *s = to_sci_port(port); in sci_free_dma()
1756 static inline void sci_request_dma(struct uart_port *port) in sci_request_dma() argument
1760 static inline void sci_free_dma(struct uart_port *port) in sci_free_dma() argument
1765 static int sci_startup(struct uart_port *port) in sci_startup() argument
1767 struct sci_port *s = to_sci_port(port); in sci_startup()
1771 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); in sci_startup()
1777 sci_request_dma(port); in sci_startup()
1779 spin_lock_irqsave(&port->lock, flags); in sci_startup()
1780 sci_start_tx(port); in sci_startup()
1781 sci_start_rx(port); in sci_startup()
1782 spin_unlock_irqrestore(&port->lock, flags); in sci_startup()
1787 static void sci_shutdown(struct uart_port *port) in sci_shutdown() argument
1789 struct sci_port *s = to_sci_port(port); in sci_shutdown()
1792 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); in sci_shutdown()
1794 spin_lock_irqsave(&port->lock, flags); in sci_shutdown()
1795 sci_stop_rx(port); in sci_shutdown()
1796 sci_stop_tx(port); in sci_shutdown()
1797 spin_unlock_irqrestore(&port->lock, flags); in sci_shutdown()
1799 sci_free_dma(port); in sci_shutdown()
1889 static void sci_reset(struct uart_port *port) in sci_reset() argument
1895 status = serial_port_in(port, SCxSR); in sci_reset()
1896 } while (!(status & SCxSR_TEND(port))); in sci_reset()
1898 serial_port_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ in sci_reset()
1900 reg = sci_getreg(port, SCFCR); in sci_reset()
1902 serial_port_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST); in sci_reset()
1905 static void sci_set_termios(struct uart_port *port, struct ktermios *termios, in sci_set_termios() argument
1908 struct sci_port *s = to_sci_port(port); in sci_set_termios()
1931 max_baud = port->uartclk ? port->uartclk / 16 : 115200; in sci_set_termios()
1933 baud = uart_get_baud_rate(port, termios, old, 0, max_baud); in sci_set_termios()
1934 if (likely(baud && port->uartclk)) { in sci_set_termios()
1937 sci_baud_calc_hscif(baud, port->uartclk, &t, &srr, in sci_set_termios()
1940 t = sci_scbrr_calc(s, baud, port->uartclk); in sci_set_termios()
1948 sci_reset(port); in sci_set_termios()
1950 smr_val |= serial_port_in(port, SCSMR) & 3; in sci_set_termios()
1952 uart_update_timeout(port, termios->c_cflag, baud); in sci_set_termios()
1954 dev_dbg(port->dev, "%s: SMR %x, cks %x, t %x, SCSCR %x\n", in sci_set_termios()
1958 serial_port_out(port, SCSMR, (smr_val & ~SCSMR_CKS) | cks); in sci_set_termios()
1959 serial_port_out(port, SCBRR, t); in sci_set_termios()
1960 reg = sci_getreg(port, HSSRR); in sci_set_termios()
1962 serial_port_out(port, HSSRR, srr | HSCIF_SRE); in sci_set_termios()
1965 serial_port_out(port, SCSMR, smr_val); in sci_set_termios()
1967 sci_init_pins(port, termios->c_cflag); in sci_set_termios()
1969 reg = sci_getreg(port, SCFCR); in sci_set_termios()
1971 unsigned short ctrl = serial_port_in(port, SCFCR); in sci_set_termios()
1987 serial_port_out(port, SCFCR, ctrl); in sci_set_termios()
1990 serial_port_out(port, SCSCR, s->cfg->scscr); in sci_set_termios()
2028 dev_dbg(port->dev, "DMA Rx t-out %ums, tty t-out %u jiffies\n", in sci_set_termios()
2029 s->rx_timeout * 1000 / HZ, port->timeout); in sci_set_termios()
2036 sci_start_rx(port); in sci_set_termios()
2041 static void sci_pm(struct uart_port *port, unsigned int state, in sci_pm() argument
2044 struct sci_port *sci_port = to_sci_port(port); in sci_pm()
2056 static const char *sci_type(struct uart_port *port) in sci_type() argument
2058 switch (port->type) { in sci_type()
2076 static inline unsigned long sci_port_size(struct uart_port *port) in sci_port_size() argument
2084 if (port->type == PORT_HSCIF) in sci_port_size()
2090 static int sci_remap_port(struct uart_port *port) in sci_remap_port() argument
2092 unsigned long size = sci_port_size(port); in sci_remap_port()
2097 if (port->membase) in sci_remap_port()
2100 if (port->flags & UPF_IOREMAP) { in sci_remap_port()
2101 port->membase = ioremap_nocache(port->mapbase, size); in sci_remap_port()
2102 if (unlikely(!port->membase)) { in sci_remap_port()
2103 dev_err(port->dev, "can't remap port#%d\n", port->line); in sci_remap_port()
2112 port->membase = (void __iomem *)(uintptr_t)port->mapbase; in sci_remap_port()
2118 static void sci_release_port(struct uart_port *port) in sci_release_port() argument
2120 if (port->flags & UPF_IOREMAP) { in sci_release_port()
2121 iounmap(port->membase); in sci_release_port()
2122 port->membase = NULL; in sci_release_port()
2125 release_mem_region(port->mapbase, sci_port_size(port)); in sci_release_port()
2128 static int sci_request_port(struct uart_port *port) in sci_request_port() argument
2130 unsigned long size = sci_port_size(port); in sci_request_port()
2134 res = request_mem_region(port->mapbase, size, dev_name(port->dev)); in sci_request_port()
2138 ret = sci_remap_port(port); in sci_request_port()
2147 static void sci_config_port(struct uart_port *port, int flags) in sci_config_port() argument
2150 struct sci_port *sport = to_sci_port(port); in sci_config_port()
2152 port->type = sport->cfg->type; in sci_config_port()
2153 sci_request_port(port); in sci_config_port()
2157 static int sci_verify_port(struct uart_port *port, struct serial_struct *ser) in sci_verify_port() argument
2193 struct uart_port *port = &sci_port->port; in sci_init_single() local
2201 port->ops = &sci_uart_ops; in sci_init_single()
2202 port->iotype = UPIO_MEM; in sci_init_single()
2203 port->line = index; in sci_init_single()
2209 port->mapbase = res->start; in sci_init_single()
2236 port->fifosize = 256; in sci_init_single()
2241 port->fifosize = 128; in sci_init_single()
2246 port->fifosize = 64; in sci_init_single()
2251 port->fifosize = 16; in sci_init_single()
2261 port->fifosize = 1; in sci_init_single()
2292 port->dev = &dev->dev; in sci_init_single()
2318 port->type = p->type; in sci_init_single()
2319 port->flags = UPF_FIXED_PORT | p->flags; in sci_init_single()
2320 port->regshift = p->regshift; in sci_init_single()
2329 port->irq = sci_port->irqs[SCIx_RXI_IRQ]; in sci_init_single()
2330 port->irqflags = 0; in sci_init_single()
2332 port->serial_in = sci_serial_in; in sci_init_single()
2333 port->serial_out = sci_serial_out; in sci_init_single()
2336 dev_dbg(port->dev, "DMA tx %d, rx %d\n", in sci_init_single()
2342 static void sci_cleanup_single(struct sci_port *port) in sci_cleanup_single() argument
2344 clk_put(port->iclk); in sci_cleanup_single()
2345 clk_put(port->fclk); in sci_cleanup_single()
2347 pm_runtime_disable(port->port.dev); in sci_cleanup_single()
2351 static void serial_console_putchar(struct uart_port *port, int ch) in serial_console_putchar() argument
2353 sci_poll_put_char(port, ch); in serial_console_putchar()
2364 struct uart_port *port = &sci_port->port; in serial_console_write() local
2370 if (port->sysrq) in serial_console_write()
2373 locked = spin_trylock(&port->lock); in serial_console_write()
2375 spin_lock(&port->lock); in serial_console_write()
2378 ctrl = serial_port_in(port, SCSCR); in serial_console_write()
2379 serial_port_out(port, SCSCR, sci_port->cfg->scscr); in serial_console_write()
2381 uart_console_write(port, s, count, serial_console_putchar); in serial_console_write()
2384 bits = SCxSR_TDxE(port) | SCxSR_TEND(port); in serial_console_write()
2385 while ((serial_port_in(port, SCxSR) & bits) != bits) in serial_console_write()
2389 serial_port_out(port, SCSCR, ctrl); in serial_console_write()
2392 spin_unlock(&port->lock); in serial_console_write()
2399 struct uart_port *port; in serial_console_setup() local
2413 port = &sci_port->port; in serial_console_setup()
2418 if (!port->ops) in serial_console_setup()
2421 ret = sci_remap_port(port); in serial_console_setup()
2428 return uart_set_options(port, co, baud, parity, bits, flow); in serial_console_setup()
2496 struct sci_port *port = platform_get_drvdata(dev); in sci_remove() local
2498 cpufreq_unregister_notifier(&port->freq_transition, in sci_remove()
2501 uart_remove_one_port(&sci_uart_driver, &port->port); in sci_remove()
2503 sci_cleanup_single(port); in sci_remove()
2604 ret = uart_add_one_port(&sci_uart_driver, &sciport->port); in sci_probe_single()
2654 uart_remove_one_port(&sci_uart_driver, &sp->port); in sci_probe()
2671 uart_suspend_port(&sci_uart_driver, &sport->port); in sci_suspend()
2681 uart_resume_port(&sci_uart_driver, &sport->port); in sci_resume()