Lines Matching refs:stm32port
640 struct stm32_port *stm32port = to_stm32_port(port); in stm32_usart_tx_dma_complete() local
643 stm32_usart_tx_dma_terminate(stm32port); in stm32_usart_tx_dma_complete()
716 struct stm32_port *stm32port = to_stm32_port(port); in stm32_usart_transmit_chars_dma() local
722 if (stm32_usart_tx_dma_started(stm32port)) { in stm32_usart_transmit_chars_dma()
723 ret = stm32_usart_tx_dma_resume(stm32port); in stm32_usart_transmit_chars_dma()
735 memcpy(&stm32port->tx_buf[0], &xmit->buf[xmit->tail], count); in stm32_usart_transmit_chars_dma()
744 memcpy(&stm32port->tx_buf[0], &xmit->buf[xmit->tail], one); in stm32_usart_transmit_chars_dma()
746 memcpy(&stm32port->tx_buf[one], &xmit->buf[0], two); in stm32_usart_transmit_chars_dma()
749 desc = dmaengine_prep_slave_single(stm32port->tx_ch, in stm32_usart_transmit_chars_dma()
750 stm32port->tx_dma_buf, in stm32_usart_transmit_chars_dma()
764 stm32port->tx_dma_busy = true; in stm32_usart_transmit_chars_dma()
774 stm32_usart_tx_dma_terminate(stm32port); in stm32_usart_transmit_chars_dma()
779 dma_async_issue_pending(stm32port->tx_ch); in stm32_usart_transmit_chars_dma()
1391 struct stm32_port *stm32port = container_of(port, in stm32_usart_pm() local
1393 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_pm()
1394 const struct stm32_usart_config *cfg = &stm32port->info->cfg; in stm32_usart_pm()
1498 static void stm32_usart_deinit_port(struct stm32_port *stm32port) in stm32_usart_deinit_port() argument
1500 clk_disable_unprepare(stm32port->clk); in stm32_usart_deinit_port()
1510 static int stm32_usart_init_port(struct stm32_port *stm32port, in stm32_usart_init_port() argument
1513 struct uart_port *port = &stm32port->port; in stm32_usart_init_port()
1525 port->fifosize = stm32port->info->cfg.fifosize; in stm32_usart_init_port()
1535 stm32port->wakeup_src = stm32port->info->cfg.has_wakeup && in stm32_usart_init_port()
1538 stm32port->swap = stm32port->info->cfg.has_swap && in stm32_usart_init_port()
1541 stm32port->fifoen = stm32port->info->cfg.has_fifo; in stm32_usart_init_port()
1542 if (stm32port->fifoen) { in stm32_usart_init_port()
1544 &stm32port->rxftcfg); in stm32_usart_init_port()
1546 &stm32port->txftcfg); in stm32_usart_init_port()
1556 stm32port->clk = devm_clk_get(&pdev->dev, NULL); in stm32_usart_init_port()
1557 if (IS_ERR(stm32port->clk)) in stm32_usart_init_port()
1558 return PTR_ERR(stm32port->clk); in stm32_usart_init_port()
1561 ret = clk_prepare_enable(stm32port->clk); in stm32_usart_init_port()
1565 stm32port->port.uartclk = clk_get_rate(stm32port->clk); in stm32_usart_init_port()
1566 if (!stm32port->port.uartclk) { in stm32_usart_init_port()
1571 stm32port->gpios = mctrl_gpio_init(&stm32port->port, 0); in stm32_usart_init_port()
1572 if (IS_ERR(stm32port->gpios)) { in stm32_usart_init_port()
1573 ret = PTR_ERR(stm32port->gpios); in stm32_usart_init_port()
1581 if (stm32port->hw_flow_control) { in stm32_usart_init_port()
1582 if (mctrl_gpio_to_gpiod(stm32port->gpios, UART_GPIO_CTS) || in stm32_usart_init_port()
1583 mctrl_gpio_to_gpiod(stm32port->gpios, UART_GPIO_RTS)) { in stm32_usart_init_port()
1593 clk_disable_unprepare(stm32port->clk); in stm32_usart_init_port()
1636 static void stm32_usart_of_dma_rx_remove(struct stm32_port *stm32port, in stm32_usart_of_dma_rx_remove() argument
1639 if (stm32port->rx_buf) in stm32_usart_of_dma_rx_remove()
1640 dma_free_coherent(&pdev->dev, RX_BUF_L, stm32port->rx_buf, in stm32_usart_of_dma_rx_remove()
1641 stm32port->rx_dma_buf); in stm32_usart_of_dma_rx_remove()
1644 static int stm32_usart_of_dma_rx_probe(struct stm32_port *stm32port, in stm32_usart_of_dma_rx_probe() argument
1647 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_of_dma_rx_probe()
1648 struct uart_port *port = &stm32port->port; in stm32_usart_of_dma_rx_probe()
1653 stm32port->rx_buf = dma_alloc_coherent(dev, RX_BUF_L, in stm32_usart_of_dma_rx_probe()
1654 &stm32port->rx_dma_buf, in stm32_usart_of_dma_rx_probe()
1656 if (!stm32port->rx_buf) in stm32_usart_of_dma_rx_probe()
1664 ret = dmaengine_slave_config(stm32port->rx_ch, &config); in stm32_usart_of_dma_rx_probe()
1667 stm32_usart_of_dma_rx_remove(stm32port, pdev); in stm32_usart_of_dma_rx_probe()
1674 static void stm32_usart_of_dma_tx_remove(struct stm32_port *stm32port, in stm32_usart_of_dma_tx_remove() argument
1677 if (stm32port->tx_buf) in stm32_usart_of_dma_tx_remove()
1678 dma_free_coherent(&pdev->dev, TX_BUF_L, stm32port->tx_buf, in stm32_usart_of_dma_tx_remove()
1679 stm32port->tx_dma_buf); in stm32_usart_of_dma_tx_remove()
1682 static int stm32_usart_of_dma_tx_probe(struct stm32_port *stm32port, in stm32_usart_of_dma_tx_probe() argument
1685 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_of_dma_tx_probe()
1686 struct uart_port *port = &stm32port->port; in stm32_usart_of_dma_tx_probe()
1691 stm32port->tx_buf = dma_alloc_coherent(dev, TX_BUF_L, in stm32_usart_of_dma_tx_probe()
1692 &stm32port->tx_dma_buf, in stm32_usart_of_dma_tx_probe()
1694 if (!stm32port->tx_buf) in stm32_usart_of_dma_tx_probe()
1702 ret = dmaengine_slave_config(stm32port->tx_ch, &config); in stm32_usart_of_dma_tx_probe()
1705 stm32_usart_of_dma_tx_remove(stm32port, pdev); in stm32_usart_of_dma_tx_probe()
1714 struct stm32_port *stm32port; in stm32_usart_serial_probe() local
1717 stm32port = stm32_usart_of_get_port(pdev); in stm32_usart_serial_probe()
1718 if (!stm32port) in stm32_usart_serial_probe()
1721 stm32port->info = of_device_get_match_data(&pdev->dev); in stm32_usart_serial_probe()
1722 if (!stm32port->info) in stm32_usart_serial_probe()
1725 stm32port->rx_ch = dma_request_chan(&pdev->dev, "rx"); in stm32_usart_serial_probe()
1726 if (PTR_ERR(stm32port->rx_ch) == -EPROBE_DEFER) in stm32_usart_serial_probe()
1730 if (IS_ERR(stm32port->rx_ch)) in stm32_usart_serial_probe()
1731 stm32port->rx_ch = NULL; in stm32_usart_serial_probe()
1733 stm32port->tx_ch = dma_request_chan(&pdev->dev, "tx"); in stm32_usart_serial_probe()
1734 if (PTR_ERR(stm32port->tx_ch) == -EPROBE_DEFER) { in stm32_usart_serial_probe()
1739 if (IS_ERR(stm32port->tx_ch)) in stm32_usart_serial_probe()
1740 stm32port->tx_ch = NULL; in stm32_usart_serial_probe()
1742 ret = stm32_usart_init_port(stm32port, pdev); in stm32_usart_serial_probe()
1746 if (stm32port->wakeup_src) { in stm32_usart_serial_probe()
1748 ret = dev_pm_set_wake_irq(&pdev->dev, stm32port->port.irq); in stm32_usart_serial_probe()
1753 if (stm32port->rx_ch && stm32_usart_of_dma_rx_probe(stm32port, pdev)) { in stm32_usart_serial_probe()
1755 dma_release_channel(stm32port->rx_ch); in stm32_usart_serial_probe()
1756 stm32port->rx_ch = NULL; in stm32_usart_serial_probe()
1759 if (stm32port->tx_ch && stm32_usart_of_dma_tx_probe(stm32port, pdev)) { in stm32_usart_serial_probe()
1761 dma_release_channel(stm32port->tx_ch); in stm32_usart_serial_probe()
1762 stm32port->tx_ch = NULL; in stm32_usart_serial_probe()
1765 if (!stm32port->rx_ch) in stm32_usart_serial_probe()
1767 if (!stm32port->tx_ch) in stm32_usart_serial_probe()
1770 platform_set_drvdata(pdev, &stm32port->port); in stm32_usart_serial_probe()
1776 ret = uart_add_one_port(&stm32_usart_driver, &stm32port->port); in stm32_usart_serial_probe()
1789 if (stm32port->tx_ch) in stm32_usart_serial_probe()
1790 stm32_usart_of_dma_tx_remove(stm32port, pdev); in stm32_usart_serial_probe()
1791 if (stm32port->rx_ch) in stm32_usart_serial_probe()
1792 stm32_usart_of_dma_rx_remove(stm32port, pdev); in stm32_usart_serial_probe()
1794 if (stm32port->wakeup_src) in stm32_usart_serial_probe()
1798 if (stm32port->wakeup_src) in stm32_usart_serial_probe()
1801 stm32_usart_deinit_port(stm32port); in stm32_usart_serial_probe()
1804 if (stm32port->tx_ch) in stm32_usart_serial_probe()
1805 dma_release_channel(stm32port->tx_ch); in stm32_usart_serial_probe()
1808 if (stm32port->rx_ch) in stm32_usart_serial_probe()
1809 dma_release_channel(stm32port->rx_ch); in stm32_usart_serial_probe()
1908 struct stm32_port *stm32port; in stm32_usart_console_setup() local
1917 stm32port = &stm32_ports[co->index]; in stm32_usart_console_setup()
1925 if (stm32port->port.mapbase == 0 || !stm32port->port.membase) in stm32_usart_console_setup()
1931 return uart_set_options(&stm32port->port, co, baud, parity, bits, flow); in stm32_usart_console_setup()
2112 struct stm32_port *stm32port = container_of(port, in stm32_usart_runtime_suspend() local
2115 clk_disable_unprepare(stm32port->clk); in stm32_usart_runtime_suspend()
2123 struct stm32_port *stm32port = container_of(port, in stm32_usart_runtime_resume() local
2126 return clk_prepare_enable(stm32port->clk); in stm32_usart_runtime_resume()