Lines Matching +full:data +full:- +full:crci
1 // SPDX-License-Identifier: GPL-2.0
13 #include <linux/dma-mapping.h>
192 writel_relaxed(val, port->membase + off); in msm_write()
198 return readl_relaxed(port->membase + off); in msm_read()
210 port->uartclk = 1843200; in msm_serial_set_mnd_regs_tcxo()
222 port->uartclk = 1843200; in msm_serial_set_mnd_regs_tcxoby4()
233 if (msm_port->is_uartdm) in msm_serial_set_mnd_regs()
236 if (port->uartclk == 19200000) in msm_serial_set_mnd_regs()
238 else if (port->uartclk == 4800000) in msm_serial_set_mnd_regs()
247 struct device *dev = port->dev; in msm_stop_dma()
251 mapped = dma->count; in msm_stop_dma()
252 dma->count = 0; in msm_stop_dma()
254 dmaengine_terminate_all(dma->chan); in msm_stop_dma()
264 val &= ~dma->enable_bit; in msm_stop_dma()
268 dma_unmap_single(dev, dma->phys, mapped, dma->dir); in msm_stop_dma()
275 dma = &msm_port->tx_dma; in msm_release_dma()
276 if (dma->chan) { in msm_release_dma()
277 msm_stop_dma(&msm_port->uart, dma); in msm_release_dma()
278 dma_release_channel(dma->chan); in msm_release_dma()
283 dma = &msm_port->rx_dma; in msm_release_dma()
284 if (dma->chan) { in msm_release_dma()
285 msm_stop_dma(&msm_port->uart, dma); in msm_release_dma()
286 dma_release_channel(dma->chan); in msm_release_dma()
287 kfree(dma->virt); in msm_release_dma()
295 struct device *dev = msm_port->uart.dev; in msm_request_tx_dma()
299 u32 crci = 0; in msm_request_tx_dma() local
302 dma = &msm_port->tx_dma; in msm_request_tx_dma()
305 dma->chan = dma_request_chan(dev, "tx"); in msm_request_tx_dma()
306 if (IS_ERR(dma->chan)) in msm_request_tx_dma()
309 of_property_read_u32(dev->of_node, "qcom,tx-crci", &crci); in msm_request_tx_dma()
316 if (crci) { in msm_request_tx_dma()
319 periph_conf.crci = crci; in msm_request_tx_dma()
322 ret = dmaengine_slave_config(dma->chan, &conf); in msm_request_tx_dma()
326 dma->dir = DMA_TO_DEVICE; in msm_request_tx_dma()
328 if (msm_port->is_uartdm < UARTDM_1P4) in msm_request_tx_dma()
329 dma->enable_bit = UARTDM_DMEN_TX_DM_ENABLE; in msm_request_tx_dma()
331 dma->enable_bit = UARTDM_DMEN_TX_BAM_ENABLE; in msm_request_tx_dma()
336 dma_release_channel(dma->chan); in msm_request_tx_dma()
343 struct device *dev = msm_port->uart.dev; in msm_request_rx_dma()
347 u32 crci = 0; in msm_request_rx_dma() local
350 dma = &msm_port->rx_dma; in msm_request_rx_dma()
353 dma->chan = dma_request_chan(dev, "rx"); in msm_request_rx_dma()
354 if (IS_ERR(dma->chan)) in msm_request_rx_dma()
357 of_property_read_u32(dev->of_node, "qcom,rx-crci", &crci); in msm_request_rx_dma()
359 dma->virt = kzalloc(UARTDM_RX_SIZE, GFP_KERNEL); in msm_request_rx_dma()
360 if (!dma->virt) in msm_request_rx_dma()
368 if (crci) { in msm_request_rx_dma()
371 periph_conf.crci = crci; in msm_request_rx_dma()
374 ret = dmaengine_slave_config(dma->chan, &conf); in msm_request_rx_dma()
378 dma->dir = DMA_FROM_DEVICE; in msm_request_rx_dma()
380 if (msm_port->is_uartdm < UARTDM_1P4) in msm_request_rx_dma()
381 dma->enable_bit = UARTDM_DMEN_RX_DM_ENABLE; in msm_request_rx_dma()
383 dma->enable_bit = UARTDM_DMEN_RX_BAM_ENABLE; in msm_request_rx_dma()
387 kfree(dma->virt); in msm_request_rx_dma()
389 dma_release_channel(dma->chan); in msm_request_rx_dma()
402 if (!timeout--) in msm_wait_for_xmitr()
412 msm_port->imr &= ~MSM_UART_IMR_TXLEV; in msm_stop_tx()
413 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_stop_tx()
419 struct msm_dma *dma = &msm_port->tx_dma; in msm_start_tx()
422 if (dma->count) in msm_start_tx()
425 msm_port->imr |= MSM_UART_IMR_TXLEV; in msm_start_tx()
426 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_start_tx()
439 struct uart_port *port = &msm_port->uart; in msm_complete_tx_dma()
440 struct circ_buf *xmit = &port->state->xmit; in msm_complete_tx_dma()
441 struct msm_dma *dma = &msm_port->tx_dma; in msm_complete_tx_dma()
447 spin_lock_irqsave(&port->lock, flags); in msm_complete_tx_dma()
450 if (!dma->count) in msm_complete_tx_dma()
453 dmaengine_tx_status(dma->chan, dma->cookie, &state); in msm_complete_tx_dma()
455 dma_unmap_single(port->dev, dma->phys, dma->count, dma->dir); in msm_complete_tx_dma()
458 val &= ~dma->enable_bit; in msm_complete_tx_dma()
461 if (msm_port->is_uartdm > UARTDM_1P3) { in msm_complete_tx_dma()
466 count = dma->count - state.residue; in msm_complete_tx_dma()
467 port->icount.tx += count; in msm_complete_tx_dma()
468 dma->count = 0; in msm_complete_tx_dma()
470 xmit->tail += count; in msm_complete_tx_dma()
471 xmit->tail &= UART_XMIT_SIZE - 1; in msm_complete_tx_dma()
474 msm_port->imr |= MSM_UART_IMR_TXLEV; in msm_complete_tx_dma()
475 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_complete_tx_dma()
482 spin_unlock_irqrestore(&port->lock, flags); in msm_complete_tx_dma()
487 struct circ_buf *xmit = &msm_port->uart.state->xmit; in msm_handle_tx_dma()
488 struct uart_port *port = &msm_port->uart; in msm_handle_tx_dma()
489 struct msm_dma *dma = &msm_port->tx_dma; in msm_handle_tx_dma()
494 cpu_addr = &xmit->buf[xmit->tail]; in msm_handle_tx_dma()
496 dma->phys = dma_map_single(port->dev, cpu_addr, count, dma->dir); in msm_handle_tx_dma()
497 ret = dma_mapping_error(port->dev, dma->phys); in msm_handle_tx_dma()
501 dma->desc = dmaengine_prep_slave_single(dma->chan, dma->phys, in msm_handle_tx_dma()
505 if (!dma->desc) { in msm_handle_tx_dma()
506 ret = -EIO; in msm_handle_tx_dma()
510 dma->desc->callback = msm_complete_tx_dma; in msm_handle_tx_dma()
511 dma->desc->callback_param = msm_port; in msm_handle_tx_dma()
513 dma->cookie = dmaengine_submit(dma->desc); in msm_handle_tx_dma()
514 ret = dma_submit_error(dma->cookie); in msm_handle_tx_dma()
522 msm_port->imr &= ~MSM_UART_IMR_TXLEV; in msm_handle_tx_dma()
523 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_handle_tx_dma()
525 dma->count = count; in msm_handle_tx_dma()
528 val |= dma->enable_bit; in msm_handle_tx_dma()
530 if (msm_port->is_uartdm < UARTDM_1P4) in msm_handle_tx_dma()
535 if (msm_port->is_uartdm > UARTDM_1P3) in msm_handle_tx_dma()
538 dma_async_issue_pending(dma->chan); in msm_handle_tx_dma()
541 dma_unmap_single(port->dev, dma->phys, count, dma->dir); in msm_handle_tx_dma()
548 struct uart_port *port = &msm_port->uart; in msm_complete_rx_dma()
549 struct tty_port *tport = &port->state->port; in msm_complete_rx_dma()
550 struct msm_dma *dma = &msm_port->rx_dma; in msm_complete_rx_dma()
555 spin_lock_irqsave(&port->lock, flags); in msm_complete_rx_dma()
558 if (!dma->count) in msm_complete_rx_dma()
562 val &= ~dma->enable_bit; in msm_complete_rx_dma()
566 port->icount.overrun++; in msm_complete_rx_dma()
573 port->icount.rx += count; in msm_complete_rx_dma()
575 dma->count = 0; in msm_complete_rx_dma()
577 dma_unmap_single(port->dev, dma->phys, UARTDM_RX_SIZE, dma->dir); in msm_complete_rx_dma()
582 if (msm_port->break_detected && dma->virt[i] == 0) { in msm_complete_rx_dma()
583 port->icount.brk++; in msm_complete_rx_dma()
585 msm_port->break_detected = false; in msm_complete_rx_dma()
590 if (!(port->read_status_mask & MSM_UART_SR_RX_BREAK)) in msm_complete_rx_dma()
593 spin_unlock_irqrestore(&port->lock, flags); in msm_complete_rx_dma()
594 sysrq = uart_handle_sysrq_char(port, dma->virt[i]); in msm_complete_rx_dma()
595 spin_lock_irqsave(&port->lock, flags); in msm_complete_rx_dma()
597 tty_insert_flip_char(tport, dma->virt[i], flag); in msm_complete_rx_dma()
602 spin_unlock_irqrestore(&port->lock, flags); in msm_complete_rx_dma()
610 struct msm_dma *dma = &msm_port->rx_dma; in msm_start_rx_dma()
611 struct uart_port *uart = &msm_port->uart; in msm_start_rx_dma()
618 if (!dma->chan) in msm_start_rx_dma()
621 dma->phys = dma_map_single(uart->dev, dma->virt, in msm_start_rx_dma()
622 UARTDM_RX_SIZE, dma->dir); in msm_start_rx_dma()
623 ret = dma_mapping_error(uart->dev, dma->phys); in msm_start_rx_dma()
627 dma->desc = dmaengine_prep_slave_single(dma->chan, dma->phys, in msm_start_rx_dma()
630 if (!dma->desc) in msm_start_rx_dma()
633 dma->desc->callback = msm_complete_rx_dma; in msm_start_rx_dma()
634 dma->desc->callback_param = msm_port; in msm_start_rx_dma()
636 dma->cookie = dmaengine_submit(dma->desc); in msm_start_rx_dma()
637 ret = dma_submit_error(dma->cookie); in msm_start_rx_dma()
641 * Using DMA for FIFO off-load, no need for "Rx FIFO over in msm_start_rx_dma()
644 msm_port->imr &= ~(MSM_UART_IMR_RXLEV | MSM_UART_IMR_RXSTALE); in msm_start_rx_dma()
650 if (msm_port->is_uartdm < UARTDM_1P4) in msm_start_rx_dma()
651 msm_port->imr |= MSM_UART_IMR_RXSTALE; in msm_start_rx_dma()
653 msm_write(uart, msm_port->imr, MSM_UART_IMR); in msm_start_rx_dma()
655 dma->count = UARTDM_RX_SIZE; in msm_start_rx_dma()
657 dma_async_issue_pending(dma->chan); in msm_start_rx_dma()
663 val |= dma->enable_bit; in msm_start_rx_dma()
665 if (msm_port->is_uartdm < UARTDM_1P4) in msm_start_rx_dma()
670 if (msm_port->is_uartdm > UARTDM_1P3) in msm_start_rx_dma()
675 dma_unmap_single(uart->dev, dma->phys, UARTDM_RX_SIZE, dma->dir); in msm_start_rx_dma()
689 /* Re-enable RX interrupts */ in msm_start_rx_dma()
690 msm_port->imr |= MSM_UART_IMR_RXLEV | MSM_UART_IMR_RXSTALE; in msm_start_rx_dma()
691 msm_write(uart, msm_port->imr, MSM_UART_IMR); in msm_start_rx_dma()
697 struct msm_dma *dma = &msm_port->rx_dma; in msm_stop_rx()
699 msm_port->imr &= ~(MSM_UART_IMR_RXLEV | MSM_UART_IMR_RXSTALE); in msm_stop_rx()
700 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_stop_rx()
702 if (dma->chan) in msm_stop_rx()
710 msm_port->imr |= MSM_UART_IMR_DELTA_CTS; in msm_enable_ms()
711 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_enable_ms()
715 __must_hold(&port->lock) in msm_handle_rx_dm()
717 struct tty_port *tport = &port->state->port; in msm_handle_rx_dm()
723 port->icount.overrun++; in msm_handle_rx_dm()
729 count = msm_read(port, UARTDM_RX_TOTAL_SNAP) - in msm_handle_rx_dm()
730 msm_port->old_snap_state; in msm_handle_rx_dm()
731 msm_port->old_snap_state = 0; in msm_handle_rx_dm()
734 msm_port->old_snap_state += count; in msm_handle_rx_dm()
739 port->icount.rx += count; in msm_handle_rx_dm()
747 msm_port->old_snap_state -= count; in msm_handle_rx_dm()
751 ioread32_rep(port->membase + UARTDM_RF, buf, 1); in msm_handle_rx_dm()
757 if (msm_port->break_detected && buf[i] == 0) { in msm_handle_rx_dm()
758 port->icount.brk++; in msm_handle_rx_dm()
760 msm_port->break_detected = false; in msm_handle_rx_dm()
765 if (!(port->read_status_mask & MSM_UART_SR_RX_BREAK)) in msm_handle_rx_dm()
768 spin_unlock(&port->lock); in msm_handle_rx_dm()
770 spin_lock(&port->lock); in msm_handle_rx_dm()
774 count -= r_count; in msm_handle_rx_dm()
789 __must_hold(&port->lock) in msm_handle_rx()
791 struct tty_port *tport = &port->state->port; in msm_handle_rx()
799 port->icount.overrun++; in msm_handle_rx()
813 port->icount.brk++; in msm_handle_rx()
817 port->icount.frame++; in msm_handle_rx()
819 port->icount.rx++; in msm_handle_rx()
823 sr &= port->read_status_mask; in msm_handle_rx()
830 spin_unlock(&port->lock); in msm_handle_rx()
832 spin_lock(&port->lock); in msm_handle_rx()
842 struct circ_buf *xmit = &port->state->xmit; in msm_handle_tx_pio()
848 if (msm_port->is_uartdm) in msm_handle_tx_pio()
849 tf = port->membase + UARTDM_TF; in msm_handle_tx_pio()
851 tf = port->membase + MSM_UART_TF; in msm_handle_tx_pio()
853 if (tx_count && msm_port->is_uartdm) in msm_handle_tx_pio()
863 if (msm_port->is_uartdm) in msm_handle_tx_pio()
864 num_chars = min(tx_count - tf_pointer, in msm_handle_tx_pio()
870 buf[i] = xmit->buf[xmit->tail + i]; in msm_handle_tx_pio()
871 port->icount.tx++; in msm_handle_tx_pio()
875 xmit->tail = (xmit->tail + num_chars) & (UART_XMIT_SIZE - 1); in msm_handle_tx_pio()
890 struct circ_buf *xmit = &msm_port->uart.state->xmit; in msm_handle_tx()
891 struct msm_dma *dma = &msm_port->tx_dma; in msm_handle_tx()
897 if (port->x_char) { in msm_handle_tx()
898 if (msm_port->is_uartdm) in msm_handle_tx()
899 tf = port->membase + UARTDM_TF; in msm_handle_tx()
901 tf = port->membase + MSM_UART_TF; in msm_handle_tx()
903 buf[0] = port->x_char; in msm_handle_tx()
905 if (msm_port->is_uartdm) in msm_handle_tx()
909 port->icount.tx++; in msm_handle_tx()
910 port->x_char = 0; in msm_handle_tx()
919 pio_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); in msm_handle_tx()
920 dma_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); in msm_handle_tx()
923 if (msm_port->is_uartdm > UARTDM_1P3) { in msm_handle_tx()
931 if (pio_count > port->fifosize) in msm_handle_tx()
932 pio_count = port->fifosize; in msm_handle_tx()
934 if (!dma->chan || dma_count < dma_min) in msm_handle_tx()
946 port->icount.cts++; in msm_handle_delta_cts()
947 wake_up_interruptible(&port->state->port.delta_msr_wait); in msm_handle_delta_cts()
954 struct msm_dma *dma = &msm_port->rx_dma; in msm_uart_irq()
959 spin_lock_irqsave(&port->lock, flags); in msm_uart_irq()
964 msm_port->break_detected = true; in msm_uart_irq()
969 if (dma->count) { in msm_uart_irq()
978 dmaengine_terminate_all(dma->chan); in msm_uart_irq()
979 } else if (msm_port->is_uartdm) { in msm_uart_irq()
990 msm_write(port, msm_port->imr, MSM_UART_IMR); /* restore interrupt */ in msm_uart_irq()
991 spin_unlock_irqrestore(&port->lock, flags); in msm_uart_irq()
1023 if (msm_port->is_uartdm) in msm_reset()
1085 target = clk_round_rate(msm_port->clk, 16 * baud); in msm_find_best_baud()
1091 if (entry->divisor <= divisor) { in msm_find_best_baud()
1092 result = target / entry->divisor / 16; in msm_find_best_baud()
1093 diff = abs(result - baud); in msm_find_best_baud()
1104 } else if (entry->divisor > divisor) { in msm_find_best_baud()
1106 target = clk_round_rate(msm_port->clk, old + 1); in msm_find_best_baud()
1135 spin_unlock_irqrestore(&port->lock, flags); in msm_set_baud_rate()
1138 clk_set_rate(msm_port->clk, rate); in msm_set_baud_rate()
1139 baud = rate / 16 / entry->divisor; in msm_set_baud_rate()
1141 spin_lock_irqsave(&port->lock, flags); in msm_set_baud_rate()
1143 port->uartclk = rate; in msm_set_baud_rate()
1145 msm_write(port, entry->code, MSM_UART_CSR); in msm_set_baud_rate()
1148 rxstale = entry->rxstale; in msm_set_baud_rate()
1150 if (msm_port->is_uartdm) { in msm_set_baud_rate()
1162 watermark = (port->fifosize * 3) / 4; in msm_set_baud_rate()
1175 msm_port->imr = MSM_UART_IMR_RXLEV | MSM_UART_IMR_RXSTALE | in msm_set_baud_rate()
1178 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_set_baud_rate()
1180 if (msm_port->is_uartdm) { in msm_set_baud_rate()
1193 clk_prepare_enable(msm_port->clk); in msm_init_clock()
1194 clk_prepare_enable(msm_port->pclk); in msm_init_clock()
1201 unsigned int data, rfr_level, mask; in msm_startup() local
1204 snprintf(msm_port->name, sizeof(msm_port->name), in msm_startup()
1205 "msm_serial%d", port->line); in msm_startup()
1209 if (likely(port->fifosize > 12)) in msm_startup()
1210 rfr_level = port->fifosize - 12; in msm_startup()
1212 rfr_level = port->fifosize; in msm_startup()
1215 data = msm_read(port, MSM_UART_MR1); in msm_startup()
1217 if (msm_port->is_uartdm) in msm_startup()
1222 data &= ~mask; in msm_startup()
1223 data &= ~MSM_UART_MR1_AUTO_RFR_LEVEL0; in msm_startup()
1224 data |= mask & (rfr_level << 2); in msm_startup()
1225 data |= MSM_UART_MR1_AUTO_RFR_LEVEL0 & rfr_level; in msm_startup()
1226 msm_write(port, data, MSM_UART_MR1); in msm_startup()
1228 if (msm_port->is_uartdm) { in msm_startup()
1229 msm_request_tx_dma(msm_port, msm_port->uart.mapbase); in msm_startup()
1230 msm_request_rx_dma(msm_port, msm_port->uart.mapbase); in msm_startup()
1233 ret = request_irq(port->irq, msm_uart_irq, IRQF_TRIGGER_HIGH, in msm_startup()
1234 msm_port->name, port); in msm_startup()
1241 if (msm_port->is_uartdm) in msm_startup()
1244 clk_disable_unprepare(msm_port->pclk); in msm_startup()
1245 clk_disable_unprepare(msm_port->clk); in msm_startup()
1254 msm_port->imr = 0; in msm_shutdown()
1257 if (msm_port->is_uartdm) in msm_shutdown()
1260 clk_disable_unprepare(msm_port->clk); in msm_shutdown()
1262 free_irq(port->irq, port); in msm_shutdown()
1269 struct msm_dma *dma = &msm_port->rx_dma; in msm_set_termios()
1273 spin_lock_irqsave(&port->lock, flags); in msm_set_termios()
1275 if (dma->chan) /* Terminate if any */ in msm_set_termios()
1287 if (termios->c_cflag & PARENB) { in msm_set_termios()
1288 if (termios->c_cflag & PARODD) in msm_set_termios()
1290 else if (termios->c_cflag & CMSPAR) in msm_set_termios()
1298 switch (termios->c_cflag & CSIZE) { in msm_set_termios()
1316 if (termios->c_cflag & CSTOPB) in msm_set_termios()
1327 if (termios->c_cflag & CRTSCTS) { in msm_set_termios()
1334 port->read_status_mask = 0; in msm_set_termios()
1335 if (termios->c_iflag & INPCK) in msm_set_termios()
1336 port->read_status_mask |= MSM_UART_SR_PAR_FRAME_ERR; in msm_set_termios()
1337 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) in msm_set_termios()
1338 port->read_status_mask |= MSM_UART_SR_RX_BREAK; in msm_set_termios()
1340 uart_update_timeout(port, termios->c_cflag, baud); in msm_set_termios()
1345 spin_unlock_irqrestore(&port->lock, flags); in msm_set_termios()
1355 struct platform_device *pdev = to_platform_device(port->dev); in msm_release_port()
1364 release_mem_region(port->mapbase, size); in msm_release_port()
1365 iounmap(port->membase); in msm_release_port()
1366 port->membase = NULL; in msm_release_port()
1371 struct platform_device *pdev = to_platform_device(port->dev); in msm_request_port()
1378 return -ENXIO; in msm_request_port()
1382 if (!request_mem_region(port->mapbase, size, "msm_serial")) in msm_request_port()
1383 return -EBUSY; in msm_request_port()
1385 port->membase = ioremap(port->mapbase, size); in msm_request_port()
1386 if (!port->membase) { in msm_request_port()
1387 ret = -EBUSY; in msm_request_port()
1394 release_mem_region(port->mapbase, size); in msm_request_port()
1403 port->type = PORT_MSM; in msm_config_port()
1412 if (unlikely(ser->type != PORT_UNKNOWN && ser->type != PORT_MSM)) in msm_verify_port()
1413 return -EINVAL; in msm_verify_port()
1414 if (unlikely(port->irq != ser->irq)) in msm_verify_port()
1415 return -EINVAL; in msm_verify_port()
1426 clk_prepare_enable(msm_port->clk); in msm_power()
1427 clk_prepare_enable(msm_port->pclk); in msm_power()
1430 clk_disable_unprepare(msm_port->clk); in msm_power()
1431 clk_disable_unprepare(msm_port->pclk); in msm_power()
1442 unsigned int rf_reg = msm_port->is_uartdm ? UARTDM_RF : MSM_UART_RF; in msm_poll_get_char_single()
1459 c = sp[sizeof(slop) - count]; in msm_poll_get_char_dm()
1460 count--; in msm_poll_get_char_dm()
1473 count--; in msm_poll_get_char_dm()
1484 count = sizeof(slop) - 1; in msm_poll_get_char_dm()
1500 if (msm_port->is_uartdm) in msm_poll_get_char()
1520 if (msm_port->is_uartdm) in msm_poll_put_char()
1528 msm_write(port, c, msm_port->is_uartdm ? UARTDM_TF : MSM_UART_TF); in msm_poll_put_char()
1612 tf = port->membase + UARTDM_TF; in __msm_console_write()
1614 tf = port->membase + MSM_UART_TF; in __msm_console_write()
1624 if (port->sysrq) in __msm_console_write()
1627 locked = spin_trylock(&port->lock); in __msm_console_write()
1629 spin_lock(&port->lock); in __msm_console_write()
1641 num_chars = min(count - i, (unsigned int)sizeof(buf)); in __msm_console_write()
1668 spin_unlock(&port->lock); in __msm_console_write()
1679 BUG_ON(co->index < 0 || co->index >= MSM_UART_NR); in msm_console_write()
1681 port = msm_get_port_from_line(co->index); in msm_console_write()
1684 __msm_console_write(port, s, count, msm_port->is_uartdm); in msm_console_write()
1695 if (unlikely(co->index >= MSM_UART_NR || co->index < 0)) in msm_console_setup()
1696 return -ENXIO; in msm_console_setup()
1698 port = msm_get_port_from_line(co->index); in msm_console_setup()
1700 if (unlikely(!port->membase)) in msm_console_setup()
1701 return -ENXIO; in msm_console_setup()
1708 pr_info("msm_serial: console setup on port #%d\n", port->line); in msm_console_setup()
1716 struct earlycon_device *dev = con->data; in msm_serial_early_write()
1718 __msm_console_write(&dev->port, s, n, false); in msm_serial_early_write()
1724 if (!device->port.membase) in msm_serial_early_console_setup()
1725 return -ENODEV; in msm_serial_early_console_setup()
1727 device->con->write = msm_serial_early_write; in msm_serial_early_console_setup()
1730 OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart",
1736 struct earlycon_device *dev = con->data; in msm_serial_early_write_dm()
1738 __msm_console_write(&dev->port, s, n, true); in msm_serial_early_write_dm()
1745 if (!device->port.membase) in msm_serial_early_console_setup_dm()
1746 return -ENODEV; in msm_serial_early_console_setup_dm()
1748 device->con->write = msm_serial_early_write_dm; in msm_serial_early_console_setup_dm()
1751 OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm",
1762 .index = -1,
1763 .data = &msm_uart_driver,
1783 { .compatible = "qcom,msm-uartdm-v1.1", .data = (void *)UARTDM_1P1 },
1784 { .compatible = "qcom,msm-uartdm-v1.2", .data = (void *)UARTDM_1P2 },
1785 { .compatible = "qcom,msm-uartdm-v1.3", .data = (void *)UARTDM_1P3 },
1786 { .compatible = "qcom,msm-uartdm-v1.4", .data = (void *)UARTDM_1P4 },
1798 if (pdev->dev.of_node) in msm_serial_probe()
1799 line = of_alias_get_id(pdev->dev.of_node, "serial"); in msm_serial_probe()
1801 line = pdev->id; in msm_serial_probe()
1804 line = atomic_inc_return(&msm_uart_next_id) - 1; in msm_serial_probe()
1807 return -ENXIO; in msm_serial_probe()
1809 dev_info(&pdev->dev, "msm_serial: detected port #%d\n", line); in msm_serial_probe()
1812 port->dev = &pdev->dev; in msm_serial_probe()
1815 id = of_match_device(msm_uartdm_table, &pdev->dev); in msm_serial_probe()
1817 msm_port->is_uartdm = (unsigned long)id->data; in msm_serial_probe()
1819 msm_port->is_uartdm = 0; in msm_serial_probe()
1821 msm_port->clk = devm_clk_get(&pdev->dev, "core"); in msm_serial_probe()
1822 if (IS_ERR(msm_port->clk)) in msm_serial_probe()
1823 return PTR_ERR(msm_port->clk); in msm_serial_probe()
1825 if (msm_port->is_uartdm) { in msm_serial_probe()
1826 msm_port->pclk = devm_clk_get(&pdev->dev, "iface"); in msm_serial_probe()
1827 if (IS_ERR(msm_port->pclk)) in msm_serial_probe()
1828 return PTR_ERR(msm_port->pclk); in msm_serial_probe()
1831 port->uartclk = clk_get_rate(msm_port->clk); in msm_serial_probe()
1832 dev_info(&pdev->dev, "uartclk = %d\n", port->uartclk); in msm_serial_probe()
1836 return -ENXIO; in msm_serial_probe()
1837 port->mapbase = resource->start; in msm_serial_probe()
1841 return -ENXIO; in msm_serial_probe()
1842 port->irq = irq; in msm_serial_probe()
1843 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MSM_CONSOLE); in msm_serial_probe()
1860 { .compatible = "qcom,msm-uart" },
1861 { .compatible = "qcom,msm-uartdm" },
1870 uart_suspend_port(&msm_uart_driver, &port->uart); in msm_serial_suspend()
1879 uart_resume_port(&msm_uart_driver, &port->uart); in msm_serial_resume()