Lines Matching refs:stm32port

642 	struct stm32_port *stm32port = to_stm32_port(port);  in stm32_usart_tx_dma_complete()  local
645 stm32_usart_tx_dma_terminate(stm32port); in stm32_usart_tx_dma_complete()
723 struct stm32_port *stm32port = to_stm32_port(port); in stm32_usart_transmit_chars_dma() local
729 if (stm32_usart_tx_dma_started(stm32port)) { in stm32_usart_transmit_chars_dma()
730 ret = stm32_usart_tx_dma_resume(stm32port); in stm32_usart_transmit_chars_dma()
736 count = kfifo_out_peek(&tport->xmit_fifo, &stm32port->tx_buf[0], in stm32_usart_transmit_chars_dma()
739 desc = dmaengine_prep_slave_single(stm32port->tx_ch, in stm32_usart_transmit_chars_dma()
740 stm32port->tx_dma_buf, in stm32_usart_transmit_chars_dma()
754 stm32port->tx_dma_busy = true; in stm32_usart_transmit_chars_dma()
764 stm32_usart_tx_dma_terminate(stm32port); in stm32_usart_transmit_chars_dma()
769 dma_async_issue_pending(stm32port->tx_ch); in stm32_usart_transmit_chars_dma()
1426 struct stm32_port *stm32port = container_of(port, in stm32_usart_pm() local
1428 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_pm()
1429 const struct stm32_usart_config *cfg = &stm32port->info->cfg; in stm32_usart_pm()
1514 static int stm32_usart_get_ftcfg(struct platform_device *pdev, struct stm32_port *stm32port, in stm32_usart_get_ftcfg() argument
1517 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_get_ftcfg()
1525 readl_relaxed(stm32port->port.membase + ofs->hwcfgr1)); in stm32_usart_get_ftcfg()
1553 static void stm32_usart_deinit_port(struct stm32_port *stm32port) in stm32_usart_deinit_port() argument
1555 clk_disable_unprepare(stm32port->clk); in stm32_usart_deinit_port()
1565 static int stm32_usart_init_port(struct stm32_port *stm32port, in stm32_usart_init_port() argument
1568 struct uart_port *port = &stm32port->port; in stm32_usart_init_port()
1589 stm32port->wakeup_src = stm32port->info->cfg.has_wakeup && in stm32_usart_init_port()
1592 stm32port->swap = stm32port->info->cfg.has_swap && in stm32_usart_init_port()
1602 stm32port->clk = devm_clk_get(&pdev->dev, NULL); in stm32_usart_init_port()
1603 if (IS_ERR(stm32port->clk)) in stm32_usart_init_port()
1604 return PTR_ERR(stm32port->clk); in stm32_usart_init_port()
1607 ret = clk_prepare_enable(stm32port->clk); in stm32_usart_init_port()
1611 stm32port->port.uartclk = clk_get_rate(stm32port->clk); in stm32_usart_init_port()
1612 if (!stm32port->port.uartclk) { in stm32_usart_init_port()
1617 stm32port->fifoen = stm32port->info->cfg.has_fifo; in stm32_usart_init_port()
1618 if (stm32port->fifoen) { in stm32_usart_init_port()
1619 stm32_usart_get_ftcfg(pdev, stm32port, "rx-threshold", &stm32port->rxftcfg); in stm32_usart_init_port()
1620 port->fifosize = stm32_usart_get_ftcfg(pdev, stm32port, "tx-threshold", in stm32_usart_init_port()
1621 &stm32port->txftcfg); in stm32_usart_init_port()
1626 stm32port->gpios = mctrl_gpio_init(&stm32port->port, 0); in stm32_usart_init_port()
1627 if (IS_ERR(stm32port->gpios)) { in stm32_usart_init_port()
1628 ret = PTR_ERR(stm32port->gpios); in stm32_usart_init_port()
1636 if (stm32port->hw_flow_control) { in stm32_usart_init_port()
1637 if (mctrl_gpio_to_gpiod(stm32port->gpios, UART_GPIO_CTS) || in stm32_usart_init_port()
1638 mctrl_gpio_to_gpiod(stm32port->gpios, UART_GPIO_RTS)) { in stm32_usart_init_port()
1648 clk_disable_unprepare(stm32port->clk); in stm32_usart_init_port()
1691 static void stm32_usart_of_dma_rx_remove(struct stm32_port *stm32port, in stm32_usart_of_dma_rx_remove() argument
1694 if (stm32port->rx_buf) in stm32_usart_of_dma_rx_remove()
1695 dma_free_coherent(&pdev->dev, RX_BUF_L, stm32port->rx_buf, in stm32_usart_of_dma_rx_remove()
1696 stm32port->rx_dma_buf); in stm32_usart_of_dma_rx_remove()
1699 static int stm32_usart_of_dma_rx_probe(struct stm32_port *stm32port, in stm32_usart_of_dma_rx_probe() argument
1702 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_of_dma_rx_probe()
1703 struct uart_port *port = &stm32port->port; in stm32_usart_of_dma_rx_probe()
1708 stm32port->rx_buf = dma_alloc_coherent(dev, RX_BUF_L, in stm32_usart_of_dma_rx_probe()
1709 &stm32port->rx_dma_buf, in stm32_usart_of_dma_rx_probe()
1711 if (!stm32port->rx_buf) in stm32_usart_of_dma_rx_probe()
1719 ret = dmaengine_slave_config(stm32port->rx_ch, &config); in stm32_usart_of_dma_rx_probe()
1722 stm32_usart_of_dma_rx_remove(stm32port, pdev); in stm32_usart_of_dma_rx_probe()
1729 static void stm32_usart_of_dma_tx_remove(struct stm32_port *stm32port, in stm32_usart_of_dma_tx_remove() argument
1732 if (stm32port->tx_buf) in stm32_usart_of_dma_tx_remove()
1733 dma_free_coherent(&pdev->dev, TX_BUF_L, stm32port->tx_buf, in stm32_usart_of_dma_tx_remove()
1734 stm32port->tx_dma_buf); in stm32_usart_of_dma_tx_remove()
1737 static int stm32_usart_of_dma_tx_probe(struct stm32_port *stm32port, in stm32_usart_of_dma_tx_probe() argument
1740 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_of_dma_tx_probe()
1741 struct uart_port *port = &stm32port->port; in stm32_usart_of_dma_tx_probe()
1746 stm32port->tx_buf = dma_alloc_coherent(dev, TX_BUF_L, in stm32_usart_of_dma_tx_probe()
1747 &stm32port->tx_dma_buf, in stm32_usart_of_dma_tx_probe()
1749 if (!stm32port->tx_buf) in stm32_usart_of_dma_tx_probe()
1757 ret = dmaengine_slave_config(stm32port->tx_ch, &config); in stm32_usart_of_dma_tx_probe()
1760 stm32_usart_of_dma_tx_remove(stm32port, pdev); in stm32_usart_of_dma_tx_probe()
1769 struct stm32_port *stm32port; in stm32_usart_serial_probe() local
1772 stm32port = stm32_usart_of_get_port(pdev); in stm32_usart_serial_probe()
1773 if (!stm32port) in stm32_usart_serial_probe()
1776 stm32port->info = of_device_get_match_data(&pdev->dev); in stm32_usart_serial_probe()
1777 if (!stm32port->info) in stm32_usart_serial_probe()
1780 stm32port->rx_ch = dma_request_chan(&pdev->dev, "rx"); in stm32_usart_serial_probe()
1781 if (PTR_ERR(stm32port->rx_ch) == -EPROBE_DEFER) in stm32_usart_serial_probe()
1785 if (IS_ERR(stm32port->rx_ch)) in stm32_usart_serial_probe()
1786 stm32port->rx_ch = NULL; in stm32_usart_serial_probe()
1788 stm32port->tx_ch = dma_request_chan(&pdev->dev, "tx"); in stm32_usart_serial_probe()
1789 if (PTR_ERR(stm32port->tx_ch) == -EPROBE_DEFER) { in stm32_usart_serial_probe()
1794 if (IS_ERR(stm32port->tx_ch)) in stm32_usart_serial_probe()
1795 stm32port->tx_ch = NULL; in stm32_usart_serial_probe()
1797 ret = stm32_usart_init_port(stm32port, pdev); in stm32_usart_serial_probe()
1801 if (stm32port->wakeup_src) { in stm32_usart_serial_probe()
1803 ret = dev_pm_set_wake_irq(&pdev->dev, stm32port->port.irq); in stm32_usart_serial_probe()
1808 if (stm32port->rx_ch && stm32_usart_of_dma_rx_probe(stm32port, pdev)) { in stm32_usart_serial_probe()
1810 dma_release_channel(stm32port->rx_ch); in stm32_usart_serial_probe()
1811 stm32port->rx_ch = NULL; in stm32_usart_serial_probe()
1814 if (stm32port->tx_ch && stm32_usart_of_dma_tx_probe(stm32port, pdev)) { in stm32_usart_serial_probe()
1816 dma_release_channel(stm32port->tx_ch); in stm32_usart_serial_probe()
1817 stm32port->tx_ch = NULL; in stm32_usart_serial_probe()
1820 if (!stm32port->rx_ch) in stm32_usart_serial_probe()
1822 if (!stm32port->tx_ch) in stm32_usart_serial_probe()
1825 platform_set_drvdata(pdev, &stm32port->port); in stm32_usart_serial_probe()
1831 ret = uart_add_one_port(&stm32_usart_driver, &stm32port->port); in stm32_usart_serial_probe()
1844 if (stm32port->tx_ch) in stm32_usart_serial_probe()
1845 stm32_usart_of_dma_tx_remove(stm32port, pdev); in stm32_usart_serial_probe()
1846 if (stm32port->rx_ch) in stm32_usart_serial_probe()
1847 stm32_usart_of_dma_rx_remove(stm32port, pdev); in stm32_usart_serial_probe()
1849 if (stm32port->wakeup_src) in stm32_usart_serial_probe()
1853 if (stm32port->wakeup_src) in stm32_usart_serial_probe()
1856 stm32_usart_deinit_port(stm32port); in stm32_usart_serial_probe()
1859 if (stm32port->tx_ch) in stm32_usart_serial_probe()
1860 dma_release_channel(stm32port->tx_ch); in stm32_usart_serial_probe()
1863 if (stm32port->rx_ch) in stm32_usart_serial_probe()
1864 dma_release_channel(stm32port->rx_ch); in stm32_usart_serial_probe()
1961 struct stm32_port *stm32port; in stm32_usart_console_setup() local
1970 stm32port = &stm32_ports[co->index]; in stm32_usart_console_setup()
1978 if (stm32port->port.mapbase == 0 || !stm32port->port.membase) in stm32_usart_console_setup()
1984 return uart_set_options(&stm32port->port, co, baud, parity, bits, flow); in stm32_usart_console_setup()
2165 struct stm32_port *stm32port = container_of(port, in stm32_usart_runtime_suspend() local
2168 clk_disable_unprepare(stm32port->clk); in stm32_usart_runtime_suspend()
2176 struct stm32_port *stm32port = container_of(port, in stm32_usart_runtime_resume() local
2179 return clk_prepare_enable(stm32port->clk); in stm32_usart_runtime_resume()