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()
468 dma->count = 0; in msm_complete_tx_dma()
471 msm_port->imr |= MSM_UART_IMR_TXLEV; in msm_complete_tx_dma()
472 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_complete_tx_dma()
479 spin_unlock_irqrestore(&port->lock, flags); in msm_complete_tx_dma()
484 struct circ_buf *xmit = &msm_port->uart.state->xmit; in msm_handle_tx_dma()
485 struct uart_port *port = &msm_port->uart; in msm_handle_tx_dma()
486 struct msm_dma *dma = &msm_port->tx_dma; in msm_handle_tx_dma()
491 cpu_addr = &xmit->buf[xmit->tail]; in msm_handle_tx_dma()
493 dma->phys = dma_map_single(port->dev, cpu_addr, count, dma->dir); in msm_handle_tx_dma()
494 ret = dma_mapping_error(port->dev, dma->phys); in msm_handle_tx_dma()
498 dma->desc = dmaengine_prep_slave_single(dma->chan, dma->phys, in msm_handle_tx_dma()
502 if (!dma->desc) { in msm_handle_tx_dma()
503 ret = -EIO; in msm_handle_tx_dma()
507 dma->desc->callback = msm_complete_tx_dma; in msm_handle_tx_dma()
508 dma->desc->callback_param = msm_port; in msm_handle_tx_dma()
510 dma->cookie = dmaengine_submit(dma->desc); in msm_handle_tx_dma()
511 ret = dma_submit_error(dma->cookie); in msm_handle_tx_dma()
519 msm_port->imr &= ~MSM_UART_IMR_TXLEV; in msm_handle_tx_dma()
520 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_handle_tx_dma()
522 dma->count = count; in msm_handle_tx_dma()
525 val |= dma->enable_bit; in msm_handle_tx_dma()
527 if (msm_port->is_uartdm < UARTDM_1P4) in msm_handle_tx_dma()
532 if (msm_port->is_uartdm > UARTDM_1P3) in msm_handle_tx_dma()
535 dma_async_issue_pending(dma->chan); in msm_handle_tx_dma()
538 dma_unmap_single(port->dev, dma->phys, count, dma->dir); in msm_handle_tx_dma()
545 struct uart_port *port = &msm_port->uart; in msm_complete_rx_dma()
546 struct tty_port *tport = &port->state->port; in msm_complete_rx_dma()
547 struct msm_dma *dma = &msm_port->rx_dma; in msm_complete_rx_dma()
552 spin_lock_irqsave(&port->lock, flags); in msm_complete_rx_dma()
555 if (!dma->count) in msm_complete_rx_dma()
559 val &= ~dma->enable_bit; in msm_complete_rx_dma()
563 port->icount.overrun++; in msm_complete_rx_dma()
570 port->icount.rx += count; in msm_complete_rx_dma()
572 dma->count = 0; in msm_complete_rx_dma()
574 dma_unmap_single(port->dev, dma->phys, UARTDM_RX_SIZE, dma->dir); in msm_complete_rx_dma()
579 if (msm_port->break_detected && dma->virt[i] == 0) { in msm_complete_rx_dma()
580 port->icount.brk++; in msm_complete_rx_dma()
582 msm_port->break_detected = false; in msm_complete_rx_dma()
587 if (!(port->read_status_mask & MSM_UART_SR_RX_BREAK)) in msm_complete_rx_dma()
590 spin_unlock_irqrestore(&port->lock, flags); in msm_complete_rx_dma()
591 sysrq = uart_handle_sysrq_char(port, dma->virt[i]); in msm_complete_rx_dma()
592 spin_lock_irqsave(&port->lock, flags); in msm_complete_rx_dma()
594 tty_insert_flip_char(tport, dma->virt[i], flag); in msm_complete_rx_dma()
599 spin_unlock_irqrestore(&port->lock, flags); in msm_complete_rx_dma()
607 struct msm_dma *dma = &msm_port->rx_dma; in msm_start_rx_dma()
608 struct uart_port *uart = &msm_port->uart; in msm_start_rx_dma()
615 if (!dma->chan) in msm_start_rx_dma()
618 dma->phys = dma_map_single(uart->dev, dma->virt, in msm_start_rx_dma()
619 UARTDM_RX_SIZE, dma->dir); in msm_start_rx_dma()
620 ret = dma_mapping_error(uart->dev, dma->phys); in msm_start_rx_dma()
624 dma->desc = dmaengine_prep_slave_single(dma->chan, dma->phys, in msm_start_rx_dma()
627 if (!dma->desc) in msm_start_rx_dma()
630 dma->desc->callback = msm_complete_rx_dma; in msm_start_rx_dma()
631 dma->desc->callback_param = msm_port; in msm_start_rx_dma()
633 dma->cookie = dmaengine_submit(dma->desc); in msm_start_rx_dma()
634 ret = dma_submit_error(dma->cookie); in msm_start_rx_dma()
638 * Using DMA for FIFO off-load, no need for "Rx FIFO over in msm_start_rx_dma()
641 msm_port->imr &= ~(MSM_UART_IMR_RXLEV | MSM_UART_IMR_RXSTALE); in msm_start_rx_dma()
647 if (msm_port->is_uartdm < UARTDM_1P4) in msm_start_rx_dma()
648 msm_port->imr |= MSM_UART_IMR_RXSTALE; in msm_start_rx_dma()
650 msm_write(uart, msm_port->imr, MSM_UART_IMR); in msm_start_rx_dma()
652 dma->count = UARTDM_RX_SIZE; in msm_start_rx_dma()
654 dma_async_issue_pending(dma->chan); in msm_start_rx_dma()
660 val |= dma->enable_bit; in msm_start_rx_dma()
662 if (msm_port->is_uartdm < UARTDM_1P4) in msm_start_rx_dma()
667 if (msm_port->is_uartdm > UARTDM_1P3) in msm_start_rx_dma()
672 dma_unmap_single(uart->dev, dma->phys, UARTDM_RX_SIZE, dma->dir); in msm_start_rx_dma()
686 /* Re-enable RX interrupts */ in msm_start_rx_dma()
687 msm_port->imr |= MSM_UART_IMR_RXLEV | MSM_UART_IMR_RXSTALE; in msm_start_rx_dma()
688 msm_write(uart, msm_port->imr, MSM_UART_IMR); in msm_start_rx_dma()
694 struct msm_dma *dma = &msm_port->rx_dma; in msm_stop_rx()
696 msm_port->imr &= ~(MSM_UART_IMR_RXLEV | MSM_UART_IMR_RXSTALE); in msm_stop_rx()
697 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_stop_rx()
699 if (dma->chan) in msm_stop_rx()
707 msm_port->imr |= MSM_UART_IMR_DELTA_CTS; in msm_enable_ms()
708 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_enable_ms()
712 __must_hold(&port->lock) in msm_handle_rx_dm()
714 struct tty_port *tport = &port->state->port; in msm_handle_rx_dm()
720 port->icount.overrun++; in msm_handle_rx_dm()
726 count = msm_read(port, UARTDM_RX_TOTAL_SNAP) - in msm_handle_rx_dm()
727 msm_port->old_snap_state; in msm_handle_rx_dm()
728 msm_port->old_snap_state = 0; in msm_handle_rx_dm()
731 msm_port->old_snap_state += count; in msm_handle_rx_dm()
736 port->icount.rx += count; in msm_handle_rx_dm()
744 msm_port->old_snap_state -= count; in msm_handle_rx_dm()
748 ioread32_rep(port->membase + UARTDM_RF, buf, 1); in msm_handle_rx_dm()
754 if (msm_port->break_detected && buf[i] == 0) { in msm_handle_rx_dm()
755 port->icount.brk++; in msm_handle_rx_dm()
757 msm_port->break_detected = false; in msm_handle_rx_dm()
762 if (!(port->read_status_mask & MSM_UART_SR_RX_BREAK)) in msm_handle_rx_dm()
765 spin_unlock(&port->lock); in msm_handle_rx_dm()
767 spin_lock(&port->lock); in msm_handle_rx_dm()
771 count -= r_count; in msm_handle_rx_dm()
786 __must_hold(&port->lock) in msm_handle_rx()
788 struct tty_port *tport = &port->state->port; in msm_handle_rx()
796 port->icount.overrun++; in msm_handle_rx()
810 port->icount.brk++; in msm_handle_rx()
814 port->icount.frame++; in msm_handle_rx()
816 port->icount.rx++; in msm_handle_rx()
820 sr &= port->read_status_mask; in msm_handle_rx()
827 spin_unlock(&port->lock); in msm_handle_rx()
829 spin_lock(&port->lock); in msm_handle_rx()
839 struct circ_buf *xmit = &port->state->xmit; in msm_handle_tx_pio()
845 if (msm_port->is_uartdm) in msm_handle_tx_pio()
846 tf = port->membase + UARTDM_TF; in msm_handle_tx_pio()
848 tf = port->membase + MSM_UART_TF; in msm_handle_tx_pio()
850 if (tx_count && msm_port->is_uartdm) in msm_handle_tx_pio()
860 if (msm_port->is_uartdm) in msm_handle_tx_pio()
861 num_chars = min(tx_count - tf_pointer, in msm_handle_tx_pio()
867 buf[i] = xmit->buf[xmit->tail + i]; in msm_handle_tx_pio()
885 struct circ_buf *xmit = &msm_port->uart.state->xmit; in msm_handle_tx()
886 struct msm_dma *dma = &msm_port->tx_dma; in msm_handle_tx()
892 if (port->x_char) { in msm_handle_tx()
893 if (msm_port->is_uartdm) in msm_handle_tx()
894 tf = port->membase + UARTDM_TF; in msm_handle_tx()
896 tf = port->membase + MSM_UART_TF; in msm_handle_tx()
898 buf[0] = port->x_char; in msm_handle_tx()
900 if (msm_port->is_uartdm) in msm_handle_tx()
904 port->icount.tx++; in msm_handle_tx()
905 port->x_char = 0; in msm_handle_tx()
914 pio_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); in msm_handle_tx()
915 dma_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); in msm_handle_tx()
918 if (msm_port->is_uartdm > UARTDM_1P3) { in msm_handle_tx()
926 if (pio_count > port->fifosize) in msm_handle_tx()
927 pio_count = port->fifosize; in msm_handle_tx()
929 if (!dma->chan || dma_count < dma_min) in msm_handle_tx()
941 port->icount.cts++; in msm_handle_delta_cts()
942 wake_up_interruptible(&port->state->port.delta_msr_wait); in msm_handle_delta_cts()
949 struct msm_dma *dma = &msm_port->rx_dma; in msm_uart_irq()
954 spin_lock_irqsave(&port->lock, flags); in msm_uart_irq()
959 msm_port->break_detected = true; in msm_uart_irq()
964 if (dma->count) { in msm_uart_irq()
973 dmaengine_terminate_all(dma->chan); in msm_uart_irq()
974 } else if (msm_port->is_uartdm) { in msm_uart_irq()
985 msm_write(port, msm_port->imr, MSM_UART_IMR); /* restore interrupt */ in msm_uart_irq()
986 spin_unlock_irqrestore(&port->lock, flags); in msm_uart_irq()
1018 if (msm_port->is_uartdm) in msm_reset()
1080 target = clk_round_rate(msm_port->clk, 16 * baud); in msm_find_best_baud()
1086 if (entry->divisor <= divisor) { in msm_find_best_baud()
1087 result = target / entry->divisor / 16; in msm_find_best_baud()
1088 diff = abs(result - baud); in msm_find_best_baud()
1099 } else if (entry->divisor > divisor) { in msm_find_best_baud()
1101 target = clk_round_rate(msm_port->clk, old + 1); in msm_find_best_baud()
1123 __must_hold(&port->lock) in msm_set_baud_rate()
1131 spin_unlock_irqrestore(&port->lock, flags); in msm_set_baud_rate()
1134 clk_set_rate(msm_port->clk, rate); in msm_set_baud_rate()
1135 baud = rate / 16 / entry->divisor; in msm_set_baud_rate()
1137 spin_lock_irqsave(&port->lock, flags); in msm_set_baud_rate()
1139 port->uartclk = rate; in msm_set_baud_rate()
1141 msm_write(port, entry->code, MSM_UART_CSR); in msm_set_baud_rate()
1144 rxstale = entry->rxstale; in msm_set_baud_rate()
1146 if (msm_port->is_uartdm) { in msm_set_baud_rate()
1158 watermark = (port->fifosize * 3) / 4; in msm_set_baud_rate()
1171 msm_port->imr = MSM_UART_IMR_RXLEV | MSM_UART_IMR_RXSTALE | in msm_set_baud_rate()
1174 msm_write(port, msm_port->imr, MSM_UART_IMR); in msm_set_baud_rate()
1176 if (msm_port->is_uartdm) { in msm_set_baud_rate()
1189 clk_prepare_enable(msm_port->clk); in msm_init_clock()
1190 clk_prepare_enable(msm_port->pclk); in msm_init_clock()
1197 unsigned int data, rfr_level, mask; in msm_startup() local
1200 snprintf(msm_port->name, sizeof(msm_port->name), in msm_startup()
1201 "msm_serial%d", port->line); in msm_startup()
1205 if (likely(port->fifosize > 12)) in msm_startup()
1206 rfr_level = port->fifosize - 12; in msm_startup()
1208 rfr_level = port->fifosize; in msm_startup()
1211 data = msm_read(port, MSM_UART_MR1); in msm_startup()
1213 if (msm_port->is_uartdm) in msm_startup()
1218 data &= ~mask; in msm_startup()
1219 data &= ~MSM_UART_MR1_AUTO_RFR_LEVEL0; in msm_startup()
1220 data |= mask & (rfr_level << 2); in msm_startup()
1221 data |= MSM_UART_MR1_AUTO_RFR_LEVEL0 & rfr_level; in msm_startup()
1222 msm_write(port, data, MSM_UART_MR1); in msm_startup()
1224 if (msm_port->is_uartdm) { in msm_startup()
1225 msm_request_tx_dma(msm_port, msm_port->uart.mapbase); in msm_startup()
1226 msm_request_rx_dma(msm_port, msm_port->uart.mapbase); in msm_startup()
1229 ret = request_irq(port->irq, msm_uart_irq, IRQF_TRIGGER_HIGH, in msm_startup()
1230 msm_port->name, port); in msm_startup()
1237 if (msm_port->is_uartdm) in msm_startup()
1240 clk_disable_unprepare(msm_port->pclk); in msm_startup()
1241 clk_disable_unprepare(msm_port->clk); in msm_startup()
1250 msm_port->imr = 0; in msm_shutdown()
1253 if (msm_port->is_uartdm) in msm_shutdown()
1256 clk_disable_unprepare(msm_port->clk); in msm_shutdown()
1258 free_irq(port->irq, port); in msm_shutdown()
1265 struct msm_dma *dma = &msm_port->rx_dma; in msm_set_termios()
1269 spin_lock_irqsave(&port->lock, flags); in msm_set_termios()
1271 if (dma->chan) /* Terminate if any */ in msm_set_termios()
1283 if (termios->c_cflag & PARENB) { in msm_set_termios()
1284 if (termios->c_cflag & PARODD) in msm_set_termios()
1286 else if (termios->c_cflag & CMSPAR) in msm_set_termios()
1294 switch (termios->c_cflag & CSIZE) { in msm_set_termios()
1312 if (termios->c_cflag & CSTOPB) in msm_set_termios()
1323 if (termios->c_cflag & CRTSCTS) { in msm_set_termios()
1330 port->read_status_mask = 0; in msm_set_termios()
1331 if (termios->c_iflag & INPCK) in msm_set_termios()
1332 port->read_status_mask |= MSM_UART_SR_PAR_FRAME_ERR; in msm_set_termios()
1333 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) in msm_set_termios()
1334 port->read_status_mask |= MSM_UART_SR_RX_BREAK; in msm_set_termios()
1336 uart_update_timeout(port, termios->c_cflag, baud); in msm_set_termios()
1341 spin_unlock_irqrestore(&port->lock, flags); in msm_set_termios()
1351 struct platform_device *pdev = to_platform_device(port->dev); in msm_release_port()
1360 release_mem_region(port->mapbase, size); in msm_release_port()
1361 iounmap(port->membase); in msm_release_port()
1362 port->membase = NULL; in msm_release_port()
1367 struct platform_device *pdev = to_platform_device(port->dev); in msm_request_port()
1374 return -ENXIO; in msm_request_port()
1378 if (!request_mem_region(port->mapbase, size, "msm_serial")) in msm_request_port()
1379 return -EBUSY; in msm_request_port()
1381 port->membase = ioremap(port->mapbase, size); in msm_request_port()
1382 if (!port->membase) { in msm_request_port()
1383 ret = -EBUSY; in msm_request_port()
1390 release_mem_region(port->mapbase, size); in msm_request_port()
1399 port->type = PORT_MSM; in msm_config_port()
1408 if (unlikely(ser->type != PORT_UNKNOWN && ser->type != PORT_MSM)) in msm_verify_port()
1409 return -EINVAL; in msm_verify_port()
1410 if (unlikely(port->irq != ser->irq)) in msm_verify_port()
1411 return -EINVAL; in msm_verify_port()
1422 clk_prepare_enable(msm_port->clk); in msm_power()
1423 clk_prepare_enable(msm_port->pclk); in msm_power()
1426 clk_disable_unprepare(msm_port->clk); in msm_power()
1427 clk_disable_unprepare(msm_port->pclk); in msm_power()
1438 unsigned int rf_reg = msm_port->is_uartdm ? UARTDM_RF : MSM_UART_RF; in msm_poll_get_char_single()
1455 c = sp[sizeof(slop) - count]; in msm_poll_get_char_dm()
1456 count--; in msm_poll_get_char_dm()
1469 count--; in msm_poll_get_char_dm()
1480 count = sizeof(slop) - 1; in msm_poll_get_char_dm()
1496 if (msm_port->is_uartdm) in msm_poll_get_char()
1516 if (msm_port->is_uartdm) in msm_poll_put_char()
1524 msm_write(port, c, msm_port->is_uartdm ? UARTDM_TF : MSM_UART_TF); in msm_poll_put_char()
1608 tf = port->membase + UARTDM_TF; in __msm_console_write()
1610 tf = port->membase + MSM_UART_TF; in __msm_console_write()
1620 if (port->sysrq) in __msm_console_write()
1623 locked = spin_trylock(&port->lock); in __msm_console_write()
1625 spin_lock(&port->lock); in __msm_console_write()
1637 num_chars = min(count - i, (unsigned int)sizeof(buf)); in __msm_console_write()
1664 spin_unlock(&port->lock); in __msm_console_write()
1675 BUG_ON(co->index < 0 || co->index >= MSM_UART_NR); in msm_console_write()
1677 port = msm_get_port_from_line(co->index); in msm_console_write()
1680 __msm_console_write(port, s, count, msm_port->is_uartdm); in msm_console_write()
1691 if (unlikely(co->index >= MSM_UART_NR || co->index < 0)) in msm_console_setup()
1692 return -ENXIO; in msm_console_setup()
1694 port = msm_get_port_from_line(co->index); in msm_console_setup()
1696 if (unlikely(!port->membase)) in msm_console_setup()
1697 return -ENXIO; in msm_console_setup()
1704 pr_info("msm_serial: console setup on port #%d\n", port->line); in msm_console_setup()
1712 struct earlycon_device *dev = con->data; in msm_serial_early_write()
1714 __msm_console_write(&dev->port, s, n, false); in msm_serial_early_write()
1720 if (!device->port.membase) in msm_serial_early_console_setup()
1721 return -ENODEV; in msm_serial_early_console_setup()
1723 device->con->write = msm_serial_early_write; in msm_serial_early_console_setup()
1726 OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart",
1732 struct earlycon_device *dev = con->data; in msm_serial_early_write_dm()
1734 __msm_console_write(&dev->port, s, n, true); in msm_serial_early_write_dm()
1741 if (!device->port.membase) in msm_serial_early_console_setup_dm()
1742 return -ENODEV; in msm_serial_early_console_setup_dm()
1744 device->con->write = msm_serial_early_write_dm; in msm_serial_early_console_setup_dm()
1747 OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm",
1758 .index = -1,
1759 .data = &msm_uart_driver,
1779 { .compatible = "qcom,msm-uartdm-v1.1", .data = (void *)UARTDM_1P1 },
1780 { .compatible = "qcom,msm-uartdm-v1.2", .data = (void *)UARTDM_1P2 },
1781 { .compatible = "qcom,msm-uartdm-v1.3", .data = (void *)UARTDM_1P3 },
1782 { .compatible = "qcom,msm-uartdm-v1.4", .data = (void *)UARTDM_1P4 },
1794 if (pdev->dev.of_node) in msm_serial_probe()
1795 line = of_alias_get_id(pdev->dev.of_node, "serial"); in msm_serial_probe()
1797 line = pdev->id; in msm_serial_probe()
1800 line = atomic_inc_return(&msm_uart_next_id) - 1; in msm_serial_probe()
1803 return -ENXIO; in msm_serial_probe()
1805 dev_info(&pdev->dev, "msm_serial: detected port #%d\n", line); in msm_serial_probe()
1808 port->dev = &pdev->dev; in msm_serial_probe()
1811 id = of_match_device(msm_uartdm_table, &pdev->dev); in msm_serial_probe()
1813 msm_port->is_uartdm = (unsigned long)id->data; in msm_serial_probe()
1815 msm_port->is_uartdm = 0; in msm_serial_probe()
1817 msm_port->clk = devm_clk_get(&pdev->dev, "core"); in msm_serial_probe()
1818 if (IS_ERR(msm_port->clk)) in msm_serial_probe()
1819 return PTR_ERR(msm_port->clk); in msm_serial_probe()
1821 if (msm_port->is_uartdm) { in msm_serial_probe()
1822 msm_port->pclk = devm_clk_get(&pdev->dev, "iface"); in msm_serial_probe()
1823 if (IS_ERR(msm_port->pclk)) in msm_serial_probe()
1824 return PTR_ERR(msm_port->pclk); in msm_serial_probe()
1827 port->uartclk = clk_get_rate(msm_port->clk); in msm_serial_probe()
1828 dev_info(&pdev->dev, "uartclk = %d\n", port->uartclk); in msm_serial_probe()
1832 return -ENXIO; in msm_serial_probe()
1833 port->mapbase = resource->start; in msm_serial_probe()
1837 return -ENXIO; in msm_serial_probe()
1838 port->irq = irq; in msm_serial_probe()
1839 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MSM_CONSOLE); in msm_serial_probe()
1856 { .compatible = "qcom,msm-uart" },
1857 { .compatible = "qcom,msm-uartdm" },
1866 uart_suspend_port(&msm_uart_driver, &port->uart); in msm_serial_suspend()
1875 uart_resume_port(&msm_uart_driver, &port->uart); in msm_serial_resume()