• Home
  • Raw
  • Download

Lines Matching +full:s3c6400 +full:- +full:uart

1 // SPDX-License-Identifier: GPL-2.0
5 * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics
12 * UERSTAT register in the UART blocks, and keeps marking some of the
21 * BJD, 04-Nov-2004
25 #include <linux/dma-mapping.h>
46 /* UART name and device definitions */
89 /* uart port features */
166 #define portaddr(port, reg) ((port)->membase + (reg))
168 ((unsigned long *)(unsigned long)((port)->membase + (reg)))
172 switch (port->iotype) { in rd_reg()
187 switch (port->iotype) { in wr_reg()
199 /* Byte-order aware bit setting/clearing functions. */
236 return to_platform_device(port->dev)->name; in s3c24xx_serial_portname()
251 spin_lock_irqsave(&port->lock, flags); in s3c24xx_serial_rx_enable()
253 while (--count && !s3c24xx_serial_txempty_nofifo(port)) in s3c24xx_serial_rx_enable()
264 ourport->rx_enabled = 1; in s3c24xx_serial_rx_enable()
265 spin_unlock_irqrestore(&port->lock, flags); in s3c24xx_serial_rx_enable()
274 spin_lock_irqsave(&port->lock, flags); in s3c24xx_serial_rx_disable()
280 ourport->rx_enabled = 0; in s3c24xx_serial_rx_disable()
281 spin_unlock_irqrestore(&port->lock, flags); in s3c24xx_serial_rx_disable()
287 struct s3c24xx_uart_dma *dma = ourport->dma; in s3c24xx_serial_stop_tx()
291 if (!ourport->tx_enabled) in s3c24xx_serial_stop_tx()
294 switch (ourport->info->type) { in s3c24xx_serial_stop_tx()
302 disable_irq_nosync(ourport->tx_irq); in s3c24xx_serial_stop_tx()
306 if (dma && dma->tx_chan && ourport->tx_in_progress == S3C24XX_TX_DMA) { in s3c24xx_serial_stop_tx()
307 dmaengine_pause(dma->tx_chan); in s3c24xx_serial_stop_tx()
308 dmaengine_tx_status(dma->tx_chan, dma->tx_cookie, &state); in s3c24xx_serial_stop_tx()
309 dmaengine_terminate_all(dma->tx_chan); in s3c24xx_serial_stop_tx()
310 dma_sync_single_for_cpu(dma->tx_chan->device->dev, in s3c24xx_serial_stop_tx()
311 dma->tx_transfer_addr, dma->tx_size, in s3c24xx_serial_stop_tx()
313 async_tx_ack(dma->tx_desc); in s3c24xx_serial_stop_tx()
314 count = dma->tx_bytes_requested - state.residue; in s3c24xx_serial_stop_tx()
318 ourport->tx_enabled = 0; in s3c24xx_serial_stop_tx()
319 ourport->tx_in_progress = 0; in s3c24xx_serial_stop_tx()
321 if (port->flags & UPF_CONS_FLOW) in s3c24xx_serial_stop_tx()
324 ourport->tx_mode = 0; in s3c24xx_serial_stop_tx()
332 struct uart_port *port = &ourport->port; in s3c24xx_serial_tx_dma_complete()
333 struct circ_buf *xmit = &port->state->xmit; in s3c24xx_serial_tx_dma_complete()
334 struct s3c24xx_uart_dma *dma = ourport->dma; in s3c24xx_serial_tx_dma_complete()
339 dmaengine_tx_status(dma->tx_chan, dma->tx_cookie, &state); in s3c24xx_serial_tx_dma_complete()
340 count = dma->tx_bytes_requested - state.residue; in s3c24xx_serial_tx_dma_complete()
341 async_tx_ack(dma->tx_desc); in s3c24xx_serial_tx_dma_complete()
343 dma_sync_single_for_cpu(dma->tx_chan->device->dev, in s3c24xx_serial_tx_dma_complete()
344 dma->tx_transfer_addr, dma->tx_size, in s3c24xx_serial_tx_dma_complete()
347 spin_lock_irqsave(&port->lock, flags); in s3c24xx_serial_tx_dma_complete()
350 ourport->tx_in_progress = 0; in s3c24xx_serial_tx_dma_complete()
356 spin_unlock_irqrestore(&port->lock, flags); in s3c24xx_serial_tx_dma_complete()
361 const struct uart_port *port = &ourport->port; in enable_tx_dma()
365 switch (ourport->info->type) { in enable_tx_dma()
373 disable_irq_nosync(ourport->tx_irq); in enable_tx_dma()
384 ourport->tx_mode = S3C24XX_TX_DMA; in enable_tx_dma()
389 const struct uart_port *port = &ourport->port; in enable_tx_pio()
393 ourport->tx_in_progress = S3C24XX_TX_PIO; in enable_tx_pio()
404 switch (ourport->info->type) { in enable_tx_pio()
414 enable_irq(ourport->tx_irq); in enable_tx_pio()
418 ourport->tx_mode = S3C24XX_TX_PIO; in enable_tx_pio()
424 if (ourport->info->type == TYPE_APPLE_S5L) in enable_tx_pio()
430 if (ourport->tx_mode != S3C24XX_TX_PIO) in s3c24xx_serial_start_tx_pio()
437 struct uart_port *port = &ourport->port; in s3c24xx_serial_start_tx_dma()
438 struct circ_buf *xmit = &port->state->xmit; in s3c24xx_serial_start_tx_dma()
439 struct s3c24xx_uart_dma *dma = ourport->dma; in s3c24xx_serial_start_tx_dma()
441 if (ourport->tx_mode != S3C24XX_TX_DMA) in s3c24xx_serial_start_tx_dma()
444 dma->tx_size = count & ~(dma_get_cache_alignment() - 1); in s3c24xx_serial_start_tx_dma()
445 dma->tx_transfer_addr = dma->tx_addr + xmit->tail; in s3c24xx_serial_start_tx_dma()
447 dma_sync_single_for_device(dma->tx_chan->device->dev, in s3c24xx_serial_start_tx_dma()
448 dma->tx_transfer_addr, dma->tx_size, in s3c24xx_serial_start_tx_dma()
451 dma->tx_desc = dmaengine_prep_slave_single(dma->tx_chan, in s3c24xx_serial_start_tx_dma()
452 dma->tx_transfer_addr, dma->tx_size, in s3c24xx_serial_start_tx_dma()
454 if (!dma->tx_desc) { in s3c24xx_serial_start_tx_dma()
455 dev_err(ourport->port.dev, "Unable to get desc for Tx\n"); in s3c24xx_serial_start_tx_dma()
456 return -EIO; in s3c24xx_serial_start_tx_dma()
459 dma->tx_desc->callback = s3c24xx_serial_tx_dma_complete; in s3c24xx_serial_start_tx_dma()
460 dma->tx_desc->callback_param = ourport; in s3c24xx_serial_start_tx_dma()
461 dma->tx_bytes_requested = dma->tx_size; in s3c24xx_serial_start_tx_dma()
463 ourport->tx_in_progress = S3C24XX_TX_DMA; in s3c24xx_serial_start_tx_dma()
464 dma->tx_cookie = dmaengine_submit(dma->tx_desc); in s3c24xx_serial_start_tx_dma()
465 dma_async_issue_pending(dma->tx_chan); in s3c24xx_serial_start_tx_dma()
471 struct uart_port *port = &ourport->port; in s3c24xx_serial_start_next_tx()
472 struct circ_buf *xmit = &port->state->xmit; in s3c24xx_serial_start_next_tx()
476 count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); in s3c24xx_serial_start_next_tx()
483 if (!ourport->dma || !ourport->dma->tx_chan || in s3c24xx_serial_start_next_tx()
484 count < ourport->min_dma_size || in s3c24xx_serial_start_next_tx()
485 xmit->tail & (dma_get_cache_alignment() - 1)) in s3c24xx_serial_start_next_tx()
494 struct circ_buf *xmit = &port->state->xmit; in s3c24xx_serial_start_tx()
496 if (!ourport->tx_enabled) { in s3c24xx_serial_start_tx()
497 if (port->flags & UPF_CONS_FLOW) in s3c24xx_serial_start_tx()
500 ourport->tx_enabled = 1; in s3c24xx_serial_start_tx()
501 if (!ourport->dma || !ourport->dma->tx_chan) in s3c24xx_serial_start_tx()
505 if (ourport->dma && ourport->dma->tx_chan) { in s3c24xx_serial_start_tx()
506 if (!uart_circ_empty(xmit) && !ourport->tx_in_progress) in s3c24xx_serial_start_tx()
514 struct s3c24xx_uart_dma *dma = ourport->dma; in s3c24xx_uart_copy_rx_to_tty()
520 dma_sync_single_for_cpu(dma->rx_chan->device->dev, dma->rx_addr, in s3c24xx_uart_copy_rx_to_tty()
521 dma->rx_size, DMA_FROM_DEVICE); in s3c24xx_uart_copy_rx_to_tty()
523 ourport->port.icount.rx += count; in s3c24xx_uart_copy_rx_to_tty()
525 dev_err(ourport->port.dev, "No tty port\n"); in s3c24xx_uart_copy_rx_to_tty()
529 ((unsigned char *)(ourport->dma->rx_buf)), count); in s3c24xx_uart_copy_rx_to_tty()
532 dev_err(ourport->port.dev, "RxData copy to tty layer failed\n"); in s3c24xx_uart_copy_rx_to_tty()
539 struct s3c24xx_uart_dma *dma = ourport->dma; in s3c24xx_serial_stop_rx()
540 struct tty_port *t = &port->state->port; in s3c24xx_serial_stop_rx()
545 if (ourport->rx_enabled) { in s3c24xx_serial_stop_rx()
546 dev_dbg(port->dev, "stopping rx\n"); in s3c24xx_serial_stop_rx()
547 switch (ourport->info->type) { in s3c24xx_serial_stop_rx()
557 disable_irq_nosync(ourport->rx_irq); in s3c24xx_serial_stop_rx()
560 ourport->rx_enabled = 0; in s3c24xx_serial_stop_rx()
562 if (dma && dma->rx_chan) { in s3c24xx_serial_stop_rx()
563 dmaengine_pause(dma->tx_chan); in s3c24xx_serial_stop_rx()
564 dma_status = dmaengine_tx_status(dma->rx_chan, in s3c24xx_serial_stop_rx()
565 dma->rx_cookie, &state); in s3c24xx_serial_stop_rx()
568 received = dma->rx_bytes_requested - state.residue; in s3c24xx_serial_stop_rx()
569 dmaengine_terminate_all(dma->rx_chan); in s3c24xx_serial_stop_rx()
578 return to_ourport(port)->info; in s3c24xx_port_to_info()
586 if (port->dev == NULL) in s3c24xx_port_to_cfg()
590 return ourport->cfg; in s3c24xx_port_to_cfg()
596 const struct s3c24xx_uart_info *info = ourport->info; in s3c24xx_serial_rx_fifocnt()
598 if (ufstat & info->rx_fifofull) in s3c24xx_serial_rx_fifocnt()
599 return ourport->port.fifosize; in s3c24xx_serial_rx_fifocnt()
601 return (ufstat & info->rx_fifomask) >> info->rx_fifoshift; in s3c24xx_serial_rx_fifocnt()
608 struct uart_port *port = &ourport->port; in s3c24xx_serial_rx_dma_complete()
610 struct s3c24xx_uart_dma *dma = ourport->dma; in s3c24xx_serial_rx_dma_complete()
611 struct tty_port *t = &port->state->port; in s3c24xx_serial_rx_dma_complete()
612 struct tty_struct *tty = tty_port_tty_get(&ourport->port.state->port); in s3c24xx_serial_rx_dma_complete()
618 dmaengine_tx_status(dma->rx_chan, dma->rx_cookie, &state); in s3c24xx_serial_rx_dma_complete()
619 received = dma->rx_bytes_requested - state.residue; in s3c24xx_serial_rx_dma_complete()
620 async_tx_ack(dma->rx_desc); in s3c24xx_serial_rx_dma_complete()
622 spin_lock_irqsave(&port->lock, flags); in s3c24xx_serial_rx_dma_complete()
634 spin_unlock_irqrestore(&port->lock, flags); in s3c24xx_serial_rx_dma_complete()
639 struct s3c24xx_uart_dma *dma = ourport->dma; in s3c64xx_start_rx_dma()
641 dma_sync_single_for_device(dma->rx_chan->device->dev, dma->rx_addr, in s3c64xx_start_rx_dma()
642 dma->rx_size, DMA_FROM_DEVICE); in s3c64xx_start_rx_dma()
644 dma->rx_desc = dmaengine_prep_slave_single(dma->rx_chan, in s3c64xx_start_rx_dma()
645 dma->rx_addr, dma->rx_size, DMA_DEV_TO_MEM, in s3c64xx_start_rx_dma()
647 if (!dma->rx_desc) { in s3c64xx_start_rx_dma()
648 dev_err(ourport->port.dev, "Unable to get desc for Rx\n"); in s3c64xx_start_rx_dma()
652 dma->rx_desc->callback = s3c24xx_serial_rx_dma_complete; in s3c64xx_start_rx_dma()
653 dma->rx_desc->callback_param = ourport; in s3c64xx_start_rx_dma()
654 dma->rx_bytes_requested = dma->rx_size; in s3c64xx_start_rx_dma()
656 dma->rx_cookie = dmaengine_submit(dma->rx_desc); in s3c64xx_start_rx_dma()
657 dma_async_issue_pending(dma->rx_chan); in s3c64xx_start_rx_dma()
660 /* ? - where has parity gone?? */
665 struct uart_port *port = &ourport->port; in enable_rx_dma()
683 ourport->rx_mode = S3C24XX_RX_DMA; in enable_rx_dma()
688 struct uart_port *port = &ourport->port; in enable_rx_pio()
697 if (ourport->info->type != TYPE_APPLE_S5L) { in enable_rx_pio()
707 ourport->rx_mode = S3C24XX_RX_PIO; in enable_rx_pio()
716 struct uart_port *port = &ourport->port; in s3c24xx_serial_rx_chars_dma()
717 struct s3c24xx_uart_dma *dma = ourport->dma; in s3c24xx_serial_rx_chars_dma()
718 struct tty_struct *tty = tty_port_tty_get(&ourport->port.state->port); in s3c24xx_serial_rx_chars_dma()
719 struct tty_port *t = &port->state->port; in s3c24xx_serial_rx_chars_dma()
725 spin_lock(&port->lock); in s3c24xx_serial_rx_chars_dma()
729 if (ourport->rx_mode == S3C24XX_RX_PIO) in s3c24xx_serial_rx_chars_dma()
734 if (ourport->rx_mode == S3C24XX_RX_DMA) { in s3c24xx_serial_rx_chars_dma()
735 dmaengine_pause(dma->rx_chan); in s3c24xx_serial_rx_chars_dma()
736 dmaengine_tx_status(dma->rx_chan, dma->rx_cookie, &state); in s3c24xx_serial_rx_chars_dma()
737 dmaengine_terminate_all(dma->rx_chan); in s3c24xx_serial_rx_chars_dma()
738 received = dma->rx_bytes_requested - state.residue; in s3c24xx_serial_rx_chars_dma()
754 spin_unlock(&port->lock); in s3c24xx_serial_rx_chars_dma()
761 struct uart_port *port = &ourport->port; in s3c24xx_serial_rx_drain_fifo()
764 int max_count = port->fifosize; in s3c24xx_serial_rx_drain_fifo()
767 while (max_count-- > 0) { in s3c24xx_serial_rx_drain_fifo()
778 fifocnt--; in s3c24xx_serial_rx_drain_fifo()
783 if (port->flags & UPF_CONS_FLOW) { in s3c24xx_serial_rx_drain_fifo()
786 if (ourport->rx_enabled) { in s3c24xx_serial_rx_drain_fifo()
788 ourport->rx_enabled = 0; in s3c24xx_serial_rx_drain_fifo()
796 ourport->rx_enabled = 1; in s3c24xx_serial_rx_drain_fifo()
806 port->icount.rx++; in s3c24xx_serial_rx_drain_fifo()
809 dev_dbg(port->dev, in s3c24xx_serial_rx_drain_fifo()
815 dev_dbg(port->dev, "break!\n"); in s3c24xx_serial_rx_drain_fifo()
816 port->icount.brk++; in s3c24xx_serial_rx_drain_fifo()
822 port->icount.frame++; in s3c24xx_serial_rx_drain_fifo()
824 port->icount.overrun++; in s3c24xx_serial_rx_drain_fifo()
826 uerstat &= port->read_status_mask; in s3c24xx_serial_rx_drain_fifo()
844 tty_flip_buffer_push(&port->state->port); in s3c24xx_serial_rx_drain_fifo()
850 struct uart_port *port = &ourport->port; in s3c24xx_serial_rx_chars_pio()
852 spin_lock(&port->lock); in s3c24xx_serial_rx_chars_pio()
854 spin_unlock(&port->lock); in s3c24xx_serial_rx_chars_pio()
863 if (ourport->dma && ourport->dma->rx_chan) in s3c24xx_serial_rx_irq()
870 struct uart_port *port = &ourport->port; in s3c24xx_serial_tx_chars()
871 struct circ_buf *xmit = &port->state->xmit; in s3c24xx_serial_tx_chars()
874 count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); in s3c24xx_serial_tx_chars()
876 if (ourport->dma && ourport->dma->tx_chan && in s3c24xx_serial_tx_chars()
877 count >= ourport->min_dma_size) { in s3c24xx_serial_tx_chars()
878 int align = dma_get_cache_alignment() - in s3c24xx_serial_tx_chars()
879 (xmit->tail & (dma_get_cache_alignment() - 1)); in s3c24xx_serial_tx_chars()
880 if (count - align >= ourport->min_dma_size) { in s3c24xx_serial_tx_chars()
881 dma_count = count - align; in s3c24xx_serial_tx_chars()
886 if (port->x_char) { in s3c24xx_serial_tx_chars()
887 wr_reg(port, S3C2410_UTXH, port->x_char); in s3c24xx_serial_tx_chars()
888 port->icount.tx++; in s3c24xx_serial_tx_chars()
889 port->x_char = 0; in s3c24xx_serial_tx_chars()
893 /* if there isn't anything more to transmit, or the uart is now in s3c24xx_serial_tx_chars()
894 * stopped, disable the uart and exit in s3c24xx_serial_tx_chars()
904 if (count > port->fifosize) { in s3c24xx_serial_tx_chars()
905 count = port->fifosize; in s3c24xx_serial_tx_chars()
910 if (rd_regl(port, S3C2410_UFSTAT) & ourport->info->tx_fifofull) in s3c24xx_serial_tx_chars()
913 wr_reg(port, S3C2410_UTXH, xmit->buf[xmit->tail]); in s3c24xx_serial_tx_chars()
915 count--; in s3c24xx_serial_tx_chars()
933 struct uart_port *port = &ourport->port; in s3c24xx_serial_tx_irq()
935 spin_lock(&port->lock); in s3c24xx_serial_tx_irq()
939 spin_unlock(&port->lock); in s3c24xx_serial_tx_irq()
947 const struct uart_port *port = &ourport->port; in s3c64xx_serial_handle_irq()
966 const struct uart_port *port = &ourport->port; in apple_serial_handle_irq()
990 if ((ufstat & info->tx_fifomask) != 0 || in s3c24xx_serial_tx_empty()
991 (ufstat & info->tx_fifofull)) in s3c24xx_serial_tx_empty()
1036 spin_lock_irqsave(&port->lock, flags); in s3c24xx_serial_break_ctl()
1047 spin_unlock_irqrestore(&port->lock, flags); in s3c24xx_serial_break_ctl()
1052 struct s3c24xx_uart_dma *dma = p->dma; in s3c24xx_serial_request_dma()
1058 dma->rx_conf.direction = DMA_DEV_TO_MEM; in s3c24xx_serial_request_dma()
1059 dma->rx_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; in s3c24xx_serial_request_dma()
1060 dma->rx_conf.src_addr = p->port.mapbase + S3C2410_URXH; in s3c24xx_serial_request_dma()
1061 dma->rx_conf.src_maxburst = 1; in s3c24xx_serial_request_dma()
1063 dma->tx_conf.direction = DMA_MEM_TO_DEV; in s3c24xx_serial_request_dma()
1064 dma->tx_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; in s3c24xx_serial_request_dma()
1065 dma->tx_conf.dst_addr = p->port.mapbase + S3C2410_UTXH; in s3c24xx_serial_request_dma()
1066 dma->tx_conf.dst_maxburst = 1; in s3c24xx_serial_request_dma()
1068 dma->rx_chan = dma_request_chan(p->port.dev, "rx"); in s3c24xx_serial_request_dma()
1070 if (IS_ERR(dma->rx_chan)) { in s3c24xx_serial_request_dma()
1072 ret = PTR_ERR(dma->rx_chan); in s3c24xx_serial_request_dma()
1076 ret = dma_get_slave_caps(dma->rx_chan, &dma_caps); in s3c24xx_serial_request_dma()
1080 ret = -EOPNOTSUPP; in s3c24xx_serial_request_dma()
1084 dmaengine_slave_config(dma->rx_chan, &dma->rx_conf); in s3c24xx_serial_request_dma()
1086 dma->tx_chan = dma_request_chan(p->port.dev, "tx"); in s3c24xx_serial_request_dma()
1087 if (IS_ERR(dma->tx_chan)) { in s3c24xx_serial_request_dma()
1089 ret = PTR_ERR(dma->tx_chan); in s3c24xx_serial_request_dma()
1093 ret = dma_get_slave_caps(dma->tx_chan, &dma_caps); in s3c24xx_serial_request_dma()
1097 ret = -EOPNOTSUPP; in s3c24xx_serial_request_dma()
1101 dmaengine_slave_config(dma->tx_chan, &dma->tx_conf); in s3c24xx_serial_request_dma()
1104 dma->rx_size = PAGE_SIZE; in s3c24xx_serial_request_dma()
1106 dma->rx_buf = kmalloc(dma->rx_size, GFP_KERNEL); in s3c24xx_serial_request_dma()
1107 if (!dma->rx_buf) { in s3c24xx_serial_request_dma()
1108 ret = -ENOMEM; in s3c24xx_serial_request_dma()
1112 dma->rx_addr = dma_map_single(dma->rx_chan->device->dev, dma->rx_buf, in s3c24xx_serial_request_dma()
1113 dma->rx_size, DMA_FROM_DEVICE); in s3c24xx_serial_request_dma()
1114 if (dma_mapping_error(dma->rx_chan->device->dev, dma->rx_addr)) { in s3c24xx_serial_request_dma()
1116 ret = -EIO; in s3c24xx_serial_request_dma()
1121 dma->tx_addr = dma_map_single(dma->tx_chan->device->dev, in s3c24xx_serial_request_dma()
1122 p->port.state->xmit.buf, UART_XMIT_SIZE, in s3c24xx_serial_request_dma()
1124 if (dma_mapping_error(dma->tx_chan->device->dev, dma->tx_addr)) { in s3c24xx_serial_request_dma()
1126 ret = -EIO; in s3c24xx_serial_request_dma()
1133 dma_unmap_single(dma->rx_chan->device->dev, dma->rx_addr, in s3c24xx_serial_request_dma()
1134 dma->rx_size, DMA_FROM_DEVICE); in s3c24xx_serial_request_dma()
1136 kfree(dma->rx_buf); in s3c24xx_serial_request_dma()
1138 dma_release_channel(dma->tx_chan); in s3c24xx_serial_request_dma()
1140 dma_release_channel(dma->rx_chan); in s3c24xx_serial_request_dma()
1143 dev_warn(p->port.dev, "%s, DMA will not be used\n", reason); in s3c24xx_serial_request_dma()
1149 struct s3c24xx_uart_dma *dma = p->dma; in s3c24xx_serial_release_dma()
1151 if (dma->rx_chan) { in s3c24xx_serial_release_dma()
1152 dmaengine_terminate_all(dma->rx_chan); in s3c24xx_serial_release_dma()
1153 dma_unmap_single(dma->rx_chan->device->dev, dma->rx_addr, in s3c24xx_serial_release_dma()
1154 dma->rx_size, DMA_FROM_DEVICE); in s3c24xx_serial_release_dma()
1155 kfree(dma->rx_buf); in s3c24xx_serial_release_dma()
1156 dma_release_channel(dma->rx_chan); in s3c24xx_serial_release_dma()
1157 dma->rx_chan = NULL; in s3c24xx_serial_release_dma()
1160 if (dma->tx_chan) { in s3c24xx_serial_release_dma()
1161 dmaengine_terminate_all(dma->tx_chan); in s3c24xx_serial_release_dma()
1162 dma_unmap_single(dma->tx_chan->device->dev, dma->tx_addr, in s3c24xx_serial_release_dma()
1164 dma_release_channel(dma->tx_chan); in s3c24xx_serial_release_dma()
1165 dma->tx_chan = NULL; in s3c24xx_serial_release_dma()
1173 if (ourport->tx_claimed) { in s3c24xx_serial_shutdown()
1174 free_irq(ourport->tx_irq, ourport); in s3c24xx_serial_shutdown()
1175 ourport->tx_enabled = 0; in s3c24xx_serial_shutdown()
1176 ourport->tx_claimed = 0; in s3c24xx_serial_shutdown()
1177 ourport->tx_mode = 0; in s3c24xx_serial_shutdown()
1180 if (ourport->rx_claimed) { in s3c24xx_serial_shutdown()
1181 free_irq(ourport->rx_irq, ourport); in s3c24xx_serial_shutdown()
1182 ourport->rx_claimed = 0; in s3c24xx_serial_shutdown()
1183 ourport->rx_enabled = 0; in s3c24xx_serial_shutdown()
1186 if (ourport->dma) in s3c24xx_serial_shutdown()
1189 ourport->tx_in_progress = 0; in s3c24xx_serial_shutdown()
1196 ourport->tx_enabled = 0; in s3c64xx_serial_shutdown()
1197 ourport->tx_mode = 0; in s3c64xx_serial_shutdown()
1198 ourport->rx_enabled = 0; in s3c64xx_serial_shutdown()
1200 free_irq(port->irq, ourport); in s3c64xx_serial_shutdown()
1205 if (ourport->dma) in s3c64xx_serial_shutdown()
1208 ourport->tx_in_progress = 0; in s3c64xx_serial_shutdown()
1225 free_irq(port->irq, ourport); in apple_s5l_serial_shutdown()
1227 ourport->tx_enabled = 0; in apple_s5l_serial_shutdown()
1228 ourport->tx_mode = 0; in apple_s5l_serial_shutdown()
1229 ourport->rx_enabled = 0; in apple_s5l_serial_shutdown()
1231 if (ourport->dma) in apple_s5l_serial_shutdown()
1234 ourport->tx_in_progress = 0; in apple_s5l_serial_shutdown()
1242 ourport->rx_enabled = 1; in s3c24xx_serial_startup()
1244 ret = request_irq(ourport->rx_irq, s3c24xx_serial_rx_irq, 0, in s3c24xx_serial_startup()
1248 dev_err(port->dev, "cannot get irq %d\n", ourport->rx_irq); in s3c24xx_serial_startup()
1252 ourport->rx_claimed = 1; in s3c24xx_serial_startup()
1254 dev_dbg(port->dev, "requesting tx irq...\n"); in s3c24xx_serial_startup()
1256 ourport->tx_enabled = 1; in s3c24xx_serial_startup()
1258 ret = request_irq(ourport->tx_irq, s3c24xx_serial_tx_irq, 0, in s3c24xx_serial_startup()
1262 dev_err(port->dev, "cannot get irq %d\n", ourport->tx_irq); in s3c24xx_serial_startup()
1266 ourport->tx_claimed = 1; in s3c24xx_serial_startup()
1287 if (ourport->dma) { in s3c64xx_serial_startup()
1290 devm_kfree(port->dev, ourport->dma); in s3c64xx_serial_startup()
1291 ourport->dma = NULL; in s3c64xx_serial_startup()
1295 ret = request_irq(port->irq, s3c64xx_serial_handle_irq, IRQF_SHARED, in s3c64xx_serial_startup()
1298 dev_err(port->dev, "cannot get irq %d\n", port->irq); in s3c64xx_serial_startup()
1303 ourport->rx_enabled = 1; in s3c64xx_serial_startup()
1304 ourport->tx_enabled = 0; in s3c64xx_serial_startup()
1306 spin_lock_irqsave(&port->lock, flags); in s3c64xx_serial_startup()
1316 spin_unlock_irqrestore(&port->lock, flags); in s3c64xx_serial_startup()
1333 ret = request_irq(port->irq, apple_serial_handle_irq, 0, in apple_s5l_serial_startup()
1336 dev_err(port->dev, "cannot get irq %d\n", port->irq); in apple_s5l_serial_startup()
1341 ourport->rx_enabled = 1; in apple_s5l_serial_startup()
1342 ourport->tx_enabled = 0; in apple_s5l_serial_startup()
1344 spin_lock_irqsave(&port->lock, flags); in apple_s5l_serial_startup()
1354 spin_unlock_irqrestore(&port->lock, flags); in apple_s5l_serial_startup()
1371 ourport->pm_level = level; in s3c24xx_serial_pm()
1375 while (--timeout && !s3c24xx_serial_txempty_nofifo(port)) in s3c24xx_serial_pm()
1378 if (!IS_ERR(ourport->baudclk)) in s3c24xx_serial_pm()
1379 clk_disable_unprepare(ourport->baudclk); in s3c24xx_serial_pm()
1381 clk_disable_unprepare(ourport->clk); in s3c24xx_serial_pm()
1385 clk_prepare_enable(ourport->clk); in s3c24xx_serial_pm()
1387 if (!IS_ERR(ourport->baudclk)) in s3c24xx_serial_pm()
1388 clk_prepare_enable(ourport->baudclk); in s3c24xx_serial_pm()
1391 dev_err(port->dev, "s3c24xx_serial: unknown pm %d\n", level); in s3c24xx_serial_pm()
1415 if (info->num_clks == 1) in s3c24xx_serial_getsource()
1419 ucon &= info->clksel_mask; in s3c24xx_serial_getsource()
1420 return ucon >> info->clksel_shift; in s3c24xx_serial_getsource()
1429 if (info->num_clks == 1) in s3c24xx_serial_setsource()
1433 if ((ucon & info->clksel_mask) >> info->clksel_shift == clk_sel) in s3c24xx_serial_setsource()
1436 ucon &= ~info->clksel_mask; in s3c24xx_serial_setsource()
1437 ucon |= clk_sel << info->clksel_shift; in s3c24xx_serial_setsource()
1445 const struct s3c24xx_uart_info *info = ourport->info; in s3c24xx_serial_getclk()
1450 int calc_deviation, deviation = (1 << 30) - 1; in s3c24xx_serial_getclk()
1452 for (cnt = 0; cnt < info->num_clks; cnt++) { in s3c24xx_serial_getclk()
1454 if (ourport->cfg->clk_sel && in s3c24xx_serial_getclk()
1455 !(ourport->cfg->clk_sel & (1 << cnt))) in s3c24xx_serial_getclk()
1459 clk = clk_get(ourport->port.dev, clkname); in s3c24xx_serial_getclk()
1465 dev_err(ourport->port.dev, in s3c24xx_serial_getclk()
1471 if (ourport->info->has_divslot) { in s3c24xx_serial_getclk()
1488 quot--; in s3c24xx_serial_getclk()
1490 calc_deviation = abs(req_baud - baud); in s3c24xx_serial_getclk()
1541 struct clk *clk = ERR_PTR(-EINVAL); in s3c24xx_serial_set_termios()
1551 termios->c_cflag &= ~(HUPCL | CMSPAR); in s3c24xx_serial_set_termios()
1552 termios->c_cflag |= CLOCAL; in s3c24xx_serial_set_termios()
1560 if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) in s3c24xx_serial_set_termios()
1561 quot = port->custom_divisor; in s3c24xx_serial_set_termios()
1567 if (ourport->baudclk != clk) { in s3c24xx_serial_set_termios()
1572 if (!IS_ERR(ourport->baudclk)) { in s3c24xx_serial_set_termios()
1573 clk_disable_unprepare(ourport->baudclk); in s3c24xx_serial_set_termios()
1574 ourport->baudclk = ERR_PTR(-EINVAL); in s3c24xx_serial_set_termios()
1577 ourport->baudclk = clk; in s3c24xx_serial_set_termios()
1578 ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0; in s3c24xx_serial_set_termios()
1581 if (ourport->info->has_divslot) { in s3c24xx_serial_set_termios()
1582 unsigned int div = ourport->baudclk_rate / baud; in s3c24xx_serial_set_termios()
1584 if (cfg->has_fracval) { in s3c24xx_serial_set_termios()
1586 dev_dbg(port->dev, "fracval = %04x\n", udivslot); in s3c24xx_serial_set_termios()
1589 dev_dbg(port->dev, "udivslot = %04x (div %d)\n", in s3c24xx_serial_set_termios()
1594 switch (termios->c_cflag & CSIZE) { in s3c24xx_serial_set_termios()
1596 dev_dbg(port->dev, "config: 5bits/char\n"); in s3c24xx_serial_set_termios()
1600 dev_dbg(port->dev, "config: 6bits/char\n"); in s3c24xx_serial_set_termios()
1604 dev_dbg(port->dev, "config: 7bits/char\n"); in s3c24xx_serial_set_termios()
1609 dev_dbg(port->dev, "config: 8bits/char\n"); in s3c24xx_serial_set_termios()
1615 ulcon |= (cfg->ulcon & S3C2410_LCON_IRM); in s3c24xx_serial_set_termios()
1617 if (termios->c_cflag & CSTOPB) in s3c24xx_serial_set_termios()
1620 if (termios->c_cflag & PARENB) { in s3c24xx_serial_set_termios()
1621 if (termios->c_cflag & PARODD) in s3c24xx_serial_set_termios()
1629 spin_lock_irqsave(&port->lock, flags); in s3c24xx_serial_set_termios()
1631 dev_dbg(port->dev, in s3c24xx_serial_set_termios()
1638 port->status &= ~UPSTAT_AUTOCTS; in s3c24xx_serial_set_termios()
1641 if (termios->c_cflag & CRTSCTS) { in s3c24xx_serial_set_termios()
1645 port->status = UPSTAT_AUTOCTS; in s3c24xx_serial_set_termios()
1651 if (ourport->info->has_divslot) in s3c24xx_serial_set_termios()
1654 dev_dbg(port->dev, in s3c24xx_serial_set_termios()
1655 "uart: ulcon = 0x%08x, ucon = 0x%08x, ufcon = 0x%08x\n", in s3c24xx_serial_set_termios()
1661 * Update the per-port timeout. in s3c24xx_serial_set_termios()
1663 uart_update_timeout(port, termios->c_cflag, baud); in s3c24xx_serial_set_termios()
1668 port->read_status_mask = S3C2410_UERSTAT_OVERRUN; in s3c24xx_serial_set_termios()
1669 if (termios->c_iflag & INPCK) in s3c24xx_serial_set_termios()
1670 port->read_status_mask |= S3C2410_UERSTAT_FRAME | in s3c24xx_serial_set_termios()
1675 port->ignore_status_mask = 0; in s3c24xx_serial_set_termios()
1676 if (termios->c_iflag & IGNPAR) in s3c24xx_serial_set_termios()
1677 port->ignore_status_mask |= S3C2410_UERSTAT_OVERRUN; in s3c24xx_serial_set_termios()
1678 if (termios->c_iflag & IGNBRK && termios->c_iflag & IGNPAR) in s3c24xx_serial_set_termios()
1679 port->ignore_status_mask |= S3C2410_UERSTAT_FRAME; in s3c24xx_serial_set_termios()
1684 if ((termios->c_cflag & CREAD) == 0) in s3c24xx_serial_set_termios()
1685 port->ignore_status_mask |= RXSTAT_DUMMY_READ; in s3c24xx_serial_set_termios()
1687 spin_unlock_irqrestore(&port->lock, flags); in s3c24xx_serial_set_termios()
1694 switch (ourport->info->type) { in s3c24xx_serial_type()
1698 return "S3C6400/10"; in s3c24xx_serial_type()
1711 port->type = info->port_type; in s3c24xx_serial_config_port()
1722 if (ser->type != PORT_UNKNOWN && ser->type != info->port_type) in s3c24xx_serial_verify_port()
1723 return -EINVAL; in s3c24xx_serial_verify_port()
1834 spin_lock_init(&port->lock); in s3c24xx_serial_init_port_default()
1836 port->iotype = UPIO_MEM; in s3c24xx_serial_init_port_default()
1837 port->uartclk = 0; in s3c24xx_serial_init_port_default()
1838 port->fifosize = 16; in s3c24xx_serial_init_port_default()
1839 port->ops = &s3c24xx_serial_ops; in s3c24xx_serial_init_port_default()
1840 port->flags = UPF_BOOT_AUTOCONF; in s3c24xx_serial_init_port_default()
1841 port->line = index; in s3c24xx_serial_init_port_default()
1855 ucon &= (info->clksel_mask | info->ucon_mask); in s3c24xx_serial_resetport()
1856 wr_regl(port, S3C2410_UCON, ucon | cfg->ucon); in s3c24xx_serial_resetport()
1859 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH); in s3c24xx_serial_resetport()
1860 wr_regl(port, S3C2410_UFCON, cfg->ufcon); in s3c24xx_serial_resetport()
1868 struct device *dev = ourport->port.dev; in s3c24xx_serial_enable_baudclk()
1869 const struct s3c24xx_uart_info *info = ourport->info; in s3c24xx_serial_enable_baudclk()
1876 clk_sel = ourport->cfg->clk_sel ? : info->def_clk_sel; in s3c24xx_serial_enable_baudclk()
1877 for (clk_num = 0; clk_num < info->num_clks; clk_num++) { in s3c24xx_serial_enable_baudclk()
1892 ourport->baudclk = clk; in s3c24xx_serial_enable_baudclk()
1893 ourport->baudclk_rate = clk_get_rate(clk); in s3c24xx_serial_enable_baudclk()
1894 s3c24xx_serial_setsource(&ourport->port, clk_num); in s3c24xx_serial_enable_baudclk()
1899 return -EINVAL; in s3c24xx_serial_enable_baudclk()
1910 struct uart_port *port = &ourport->port; in s3c24xx_serial_init_port()
1911 const struct s3c2410_uartcfg *cfg = ourport->cfg; in s3c24xx_serial_init_port()
1916 return -ENODEV; in s3c24xx_serial_init_port()
1918 if (port->mapbase != 0) in s3c24xx_serial_init_port()
1919 return -EINVAL; in s3c24xx_serial_init_port()
1922 port->dev = &platdev->dev; in s3c24xx_serial_init_port()
1924 port->uartclk = 1; in s3c24xx_serial_init_port()
1926 if (cfg->uart_flags & UPF_CONS_FLOW) { in s3c24xx_serial_init_port()
1927 dev_dbg(port->dev, "enabling flow control\n"); in s3c24xx_serial_init_port()
1928 port->flags |= UPF_CONS_FLOW; in s3c24xx_serial_init_port()
1931 /* sort our the physical and virtual addresses for each UART */ in s3c24xx_serial_init_port()
1935 dev_err(port->dev, "failed to find memory resource for uart\n"); in s3c24xx_serial_init_port()
1936 return -EINVAL; in s3c24xx_serial_init_port()
1939 dev_dbg(port->dev, "resource %pR)\n", res); in s3c24xx_serial_init_port()
1941 port->membase = devm_ioremap_resource(port->dev, res); in s3c24xx_serial_init_port()
1942 if (IS_ERR(port->membase)) { in s3c24xx_serial_init_port()
1943 dev_err(port->dev, "failed to remap controller address\n"); in s3c24xx_serial_init_port()
1944 return -EBUSY; in s3c24xx_serial_init_port()
1947 port->mapbase = res->start; in s3c24xx_serial_init_port()
1950 port->irq = 0; in s3c24xx_serial_init_port()
1952 port->irq = ret; in s3c24xx_serial_init_port()
1953 ourport->rx_irq = ret; in s3c24xx_serial_init_port()
1954 ourport->tx_irq = ret + 1; in s3c24xx_serial_init_port()
1957 switch (ourport->info->type) { in s3c24xx_serial_init_port()
1961 ourport->tx_irq = ret; in s3c24xx_serial_init_port()
1971 if (platdev->dev.of_node && of_find_property(platdev->dev.of_node, in s3c24xx_serial_init_port()
1973 ourport->dma = devm_kzalloc(port->dev, in s3c24xx_serial_init_port()
1974 sizeof(*ourport->dma), in s3c24xx_serial_init_port()
1976 if (!ourport->dma) { in s3c24xx_serial_init_port()
1977 ret = -ENOMEM; in s3c24xx_serial_init_port()
1982 ourport->clk = clk_get(&platdev->dev, "uart"); in s3c24xx_serial_init_port()
1983 if (IS_ERR(ourport->clk)) { in s3c24xx_serial_init_port()
1985 dev_name(&platdev->dev)); in s3c24xx_serial_init_port()
1986 ret = PTR_ERR(ourport->clk); in s3c24xx_serial_init_port()
1990 ret = clk_prepare_enable(ourport->clk); in s3c24xx_serial_init_port()
1992 pr_err("uart: clock failed to prepare+enable: %d\n", ret); in s3c24xx_serial_init_port()
1993 clk_put(ourport->clk); in s3c24xx_serial_init_port()
1999 pr_warn("uart: failed to enable baudclk\n"); in s3c24xx_serial_init_port()
2002 switch (ourport->info->type) { in s3c24xx_serial_init_port()
2024 dev_dbg(port->dev, "port: map=%pa, mem=%p, irq=%d (%d,%d), clock=%u\n", in s3c24xx_serial_init_port()
2025 &port->mapbase, port->membase, port->irq, in s3c24xx_serial_init_port()
2026 ourport->rx_irq, ourport->tx_irq, port->uartclk); in s3c24xx_serial_init_port()
2028 /* reset the fifos (and setup the uart) */ in s3c24xx_serial_init_port()
2034 port->mapbase = 0; in s3c24xx_serial_init_port()
2045 if (dev_of_node(&pdev->dev)) in s3c24xx_get_driver_data()
2046 return of_device_get_match_data(&pdev->dev); in s3c24xx_get_driver_data()
2049 platform_get_device_id(pdev)->driver_data; in s3c24xx_get_driver_data()
2054 struct device_node *np = pdev->dev.of_node; in s3c24xx_serial_probe()
2066 dev_err(&pdev->dev, "serial%d out of range\n", index); in s3c24xx_serial_probe()
2067 return -EINVAL; in s3c24xx_serial_probe()
2073 ourport->drv_data = s3c24xx_get_driver_data(pdev); in s3c24xx_serial_probe()
2074 if (!ourport->drv_data) { in s3c24xx_serial_probe()
2075 dev_err(&pdev->dev, "could not find driver data\n"); in s3c24xx_serial_probe()
2076 return -ENODEV; in s3c24xx_serial_probe()
2079 ourport->baudclk = ERR_PTR(-EINVAL); in s3c24xx_serial_probe()
2080 ourport->info = &ourport->drv_data->info; in s3c24xx_serial_probe()
2081 ourport->cfg = (dev_get_platdata(&pdev->dev)) ? in s3c24xx_serial_probe()
2082 dev_get_platdata(&pdev->dev) : in s3c24xx_serial_probe()
2083 &ourport->drv_data->def_cfg; in s3c24xx_serial_probe()
2085 switch (ourport->info->type) { in s3c24xx_serial_probe()
2087 ourport->port.ops = &s3c24xx_serial_ops; in s3c24xx_serial_probe()
2090 ourport->port.ops = &s3c64xx_serial_ops; in s3c24xx_serial_probe()
2093 ourport->port.ops = &apple_s5l_serial_ops; in s3c24xx_serial_probe()
2099 "samsung,uart-fifosize", &ourport->port.fifosize); in s3c24xx_serial_probe()
2101 if (of_property_read_u32(np, "reg-io-width", &prop) == 0) { in s3c24xx_serial_probe()
2104 ourport->port.iotype = UPIO_MEM; in s3c24xx_serial_probe()
2107 ourport->port.iotype = UPIO_MEM32; in s3c24xx_serial_probe()
2110 dev_warn(&pdev->dev, "unsupported reg-io-width (%d)\n", in s3c24xx_serial_probe()
2112 return -EINVAL; in s3c24xx_serial_probe()
2117 if (ourport->drv_data->fifosize[index]) in s3c24xx_serial_probe()
2118 ourport->port.fifosize = ourport->drv_data->fifosize[index]; in s3c24xx_serial_probe()
2119 else if (ourport->info->fifosize) in s3c24xx_serial_probe()
2120 ourport->port.fifosize = ourport->info->fifosize; in s3c24xx_serial_probe()
2121 ourport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SAMSUNG_CONSOLE); in s3c24xx_serial_probe()
2127 ourport->min_dma_size = max_t(int, ourport->port.fifosize, in s3c24xx_serial_probe()
2130 dev_dbg(&pdev->dev, "%s: initialising port %p...\n", __func__, ourport); in s3c24xx_serial_probe()
2139 pr_err("Failed to register Samsung UART driver\n"); in s3c24xx_serial_probe()
2144 dev_dbg(&pdev->dev, "%s: adding port\n", __func__); in s3c24xx_serial_probe()
2145 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port); in s3c24xx_serial_probe()
2146 platform_set_drvdata(pdev, &ourport->port); in s3c24xx_serial_probe()
2150 * so that a potential re-enablement through the pm-callback overlaps in s3c24xx_serial_probe()
2153 clk_disable_unprepare(ourport->clk); in s3c24xx_serial_probe()
2154 if (!IS_ERR(ourport->baudclk)) in s3c24xx_serial_probe()
2155 clk_disable_unprepare(ourport->baudclk); in s3c24xx_serial_probe()
2164 struct uart_port *port = s3c24xx_dev_to_port(&dev->dev); in s3c24xx_serial_remove()
2175 /* UART power management code */
2193 clk_prepare_enable(ourport->clk); in s3c24xx_serial_resume()
2194 if (!IS_ERR(ourport->baudclk)) in s3c24xx_serial_resume()
2195 clk_prepare_enable(ourport->baudclk); in s3c24xx_serial_resume()
2197 if (!IS_ERR(ourport->baudclk)) in s3c24xx_serial_resume()
2198 clk_disable_unprepare(ourport->baudclk); in s3c24xx_serial_resume()
2199 clk_disable_unprepare(ourport->clk); in s3c24xx_serial_resume()
2214 switch (ourport->info->type) { in s3c24xx_serial_resume_noirq()
2218 if (ourport->tx_enabled) in s3c24xx_serial_resume_noirq()
2220 if (ourport->rx_enabled) in s3c24xx_serial_resume_noirq()
2222 clk_prepare_enable(ourport->clk); in s3c24xx_serial_resume_noirq()
2223 if (!IS_ERR(ourport->baudclk)) in s3c24xx_serial_resume_noirq()
2224 clk_prepare_enable(ourport->baudclk); in s3c24xx_serial_resume_noirq()
2226 if (!IS_ERR(ourport->baudclk)) in s3c24xx_serial_resume_noirq()
2227 clk_disable_unprepare(ourport->baudclk); in s3c24xx_serial_resume_noirq()
2228 clk_disable_unprepare(ourport->clk); in s3c24xx_serial_resume_noirq()
2235 ret = clk_prepare_enable(ourport->clk); in s3c24xx_serial_resume_noirq()
2240 if (!IS_ERR(ourport->baudclk)) { in s3c24xx_serial_resume_noirq()
2241 ret = clk_prepare_enable(ourport->baudclk); in s3c24xx_serial_resume_noirq()
2244 clk_disable_unprepare(ourport->clk); in s3c24xx_serial_resume_noirq()
2255 if (ourport->tx_enabled) in s3c24xx_serial_resume_noirq()
2257 if (ourport->rx_enabled) in s3c24xx_serial_resume_noirq()
2263 if (!IS_ERR(ourport->baudclk)) in s3c24xx_serial_resume_noirq()
2264 clk_disable_unprepare(ourport->baudclk); in s3c24xx_serial_resume_noirq()
2265 clk_disable_unprepare(ourport->clk); in s3c24xx_serial_resume_noirq()
2300 /* fifo mode - check amount of data in fifo registers... */ in s3c24xx_serial_console_txrdy()
2303 return (ufstat & info->tx_fifofull) ? 0 : 1; in s3c24xx_serial_console_txrdy()
2306 /* in non-fifo mode, we go and use the tx buffer empty */ in s3c24xx_serial_console_txrdy()
2321 * Console polling routines for writing and reading from the uart while
2376 if (cons_uart->sysrq) in s3c24xx_serial_console_write()
2379 locked = spin_trylock_irqsave(&cons_uart->lock, flags); in s3c24xx_serial_console_write()
2381 spin_lock_irqsave(&cons_uart->lock, flags); in s3c24xx_serial_console_write()
2386 spin_unlock_irqrestore(&cons_uart->lock, flags); in s3c24xx_serial_console_write()
2442 clk = clk_get(port->dev, clk_name); in s3c24xx_serial_get_options()
2449 dev_dbg(port->dev, "calculated baud %d\n", *baud); in s3c24xx_serial_get_options()
2465 if (co->index == -1 || co->index >= UART_NR) in s3c24xx_serial_console_setup()
2466 co->index = 0; in s3c24xx_serial_console_setup()
2468 port = &s3c24xx_serial_ports[co->index].port; in s3c24xx_serial_console_setup()
2472 if (port->mapbase == 0x0) in s3c24xx_serial_console_setup()
2473 return -ENODEV; in s3c24xx_serial_console_setup()
2478 * Check whether an invalid uart number has been specified, and in s3c24xx_serial_console_setup()
2487 dev_dbg(port->dev, "baud %d\n", baud); in s3c24xx_serial_console_setup()
2496 .index = -1,
2506 .name = "Samsung S3C6400 UART",
2535 .name = "Samsung S5PV210 UART",
2564 .name = "Samsung Exynos UART", \
2613 .name = "Apple S5L UART",
2642 .name = "Axis ARTPEC-8 UART",
2671 .name = "s3c6400-uart",
2674 .name = "s5pv210-uart",
2677 .name = "exynos4210-uart",
2680 .name = "exynos5433-uart",
2683 .name = "s5l-uart",
2686 .name = "exynos850-uart",
2689 .name = "artpec8-uart",
2698 { .compatible = "samsung,s3c6400-uart",
2700 { .compatible = "samsung,s5pv210-uart",
2702 { .compatible = "samsung,exynos4210-uart",
2704 { .compatible = "samsung,exynos5433-uart",
2706 { .compatible = "apple,s5l-uart",
2708 { .compatible = "samsung,exynos850-uart",
2710 { .compatible = "axis,artpec8-uart",
2722 .name = "samsung-uart",
2759 switch (port->iotype) { in wr_reg_barrier()
2776 while (!(readl(port->membase + S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXFE)) in samsung_early_busyuart()
2782 const struct samsung_early_console_data *data = port->private_data; in samsung_early_busyuart_fifo()
2784 while (readl(port->membase + S3C2410_UFSTAT) & data->txfull_mask) in samsung_early_busyuart_fifo()
2790 if (readl(port->membase + S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) in samsung_early_putc()
2801 struct earlycon_device *dev = con->data; in samsung_early_write()
2803 uart_console_write(&dev->port, s, n, samsung_early_putc); in samsung_early_write()
2808 struct earlycon_device *dev = con->data; in samsung_early_read()
2809 const struct samsung_early_console_data *data = dev->port.private_data; in samsung_early_read()
2813 ufstat = rd_regl(&dev->port, S3C2410_UFSTAT); in samsung_early_read()
2814 if (!(ufstat & data->rxfifo_mask)) in samsung_early_read()
2816 ch = rd_reg(&dev->port, S3C2410_URXH); in samsung_early_read()
2829 if (!device->port.membase) in samsung_early_console_setup()
2830 return -ENODEV; in samsung_early_console_setup()
2832 device->con->write = samsung_early_write; in samsung_early_console_setup()
2833 device->con->read = samsung_early_read; in samsung_early_console_setup()
2846 device->port.private_data = &s3c2410_early_console_data; in s3c2410_early_console_setup()
2850 OF_EARLYCON_DECLARE(s3c2410, "samsung,s3c2410-uart",
2862 device->port.private_data = &s3c2440_early_console_data; in s3c2440_early_console_setup()
2866 OF_EARLYCON_DECLARE(s3c2412, "samsung,s3c2412-uart",
2868 OF_EARLYCON_DECLARE(s3c2440, "samsung,s3c2440-uart",
2870 OF_EARLYCON_DECLARE(s3c6400, "samsung,s3c6400-uart",
2882 device->port.private_data = &s5pv210_early_console_data; in s5pv210_early_console_setup()
2886 OF_EARLYCON_DECLARE(s5pv210, "samsung,s5pv210-uart",
2888 OF_EARLYCON_DECLARE(exynos4210, "samsung,exynos4210-uart",
2890 OF_EARLYCON_DECLARE(artpec8, "axis,artpec8-uart",
2898 device->port.private_data = &s3c2410_early_console_data; in apple_s5l_early_console_setup()
2902 __set_fixmap(FIX_EARLYCON_MEM_BASE, device->port.mapbase, in apple_s5l_early_console_setup()
2908 OF_EARLYCON_DECLARE(s5l, "apple,s5l-uart", apple_s5l_early_console_setup);
2911 MODULE_ALIAS("platform:samsung-uart");