Lines Matching refs:stm32port
516 struct stm32_port *stm32port = to_stm32_port(port); in stm32_usart_tx_dma_complete() local
517 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_tx_dma_complete()
521 stm32_usart_tx_dma_terminate(stm32port); in stm32_usart_tx_dma_complete()
612 struct stm32_port *stm32port = to_stm32_port(port); in stm32_usart_transmit_chars_dma() local
613 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_transmit_chars_dma()
618 if (stm32_usart_tx_dma_started(stm32port)) { in stm32_usart_transmit_chars_dma()
619 if (!stm32_usart_tx_dma_enabled(stm32port)) in stm32_usart_transmit_chars_dma()
630 memcpy(&stm32port->tx_buf[0], &xmit->buf[xmit->tail], count); in stm32_usart_transmit_chars_dma()
639 memcpy(&stm32port->tx_buf[0], &xmit->buf[xmit->tail], one); in stm32_usart_transmit_chars_dma()
641 memcpy(&stm32port->tx_buf[one], &xmit->buf[0], two); in stm32_usart_transmit_chars_dma()
644 desc = dmaengine_prep_slave_single(stm32port->tx_ch, in stm32_usart_transmit_chars_dma()
645 stm32port->tx_dma_buf, in stm32_usart_transmit_chars_dma()
659 stm32port->tx_dma_busy = true; in stm32_usart_transmit_chars_dma()
667 stm32_usart_tx_dma_terminate(stm32port); in stm32_usart_transmit_chars_dma()
672 dma_async_issue_pending(stm32port->tx_ch); in stm32_usart_transmit_chars_dma()
1343 struct stm32_port *stm32port = container_of(port, in stm32_usart_pm() local
1345 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_pm()
1346 const struct stm32_usart_config *cfg = &stm32port->info->cfg; in stm32_usart_pm()
1450 static void stm32_usart_deinit_port(struct stm32_port *stm32port) in stm32_usart_deinit_port() argument
1452 clk_disable_unprepare(stm32port->clk); in stm32_usart_deinit_port()
1462 static int stm32_usart_init_port(struct stm32_port *stm32port, in stm32_usart_init_port() argument
1465 struct uart_port *port = &stm32port->port; in stm32_usart_init_port()
1477 port->fifosize = stm32port->info->cfg.fifosize; in stm32_usart_init_port()
1487 stm32port->wakeup_src = stm32port->info->cfg.has_wakeup && in stm32_usart_init_port()
1490 stm32port->swap = stm32port->info->cfg.has_swap && in stm32_usart_init_port()
1493 stm32port->fifoen = stm32port->info->cfg.has_fifo; in stm32_usart_init_port()
1494 if (stm32port->fifoen) { in stm32_usart_init_port()
1496 &stm32port->rxftcfg); in stm32_usart_init_port()
1498 &stm32port->txftcfg); in stm32_usart_init_port()
1508 stm32port->clk = devm_clk_get(&pdev->dev, NULL); in stm32_usart_init_port()
1509 if (IS_ERR(stm32port->clk)) in stm32_usart_init_port()
1510 return PTR_ERR(stm32port->clk); in stm32_usart_init_port()
1513 ret = clk_prepare_enable(stm32port->clk); in stm32_usart_init_port()
1517 stm32port->port.uartclk = clk_get_rate(stm32port->clk); in stm32_usart_init_port()
1518 if (!stm32port->port.uartclk) { in stm32_usart_init_port()
1523 stm32port->gpios = mctrl_gpio_init(&stm32port->port, 0); in stm32_usart_init_port()
1524 if (IS_ERR(stm32port->gpios)) { in stm32_usart_init_port()
1525 ret = PTR_ERR(stm32port->gpios); in stm32_usart_init_port()
1533 if (stm32port->hw_flow_control) { in stm32_usart_init_port()
1534 if (mctrl_gpio_to_gpiod(stm32port->gpios, UART_GPIO_CTS) || in stm32_usart_init_port()
1535 mctrl_gpio_to_gpiod(stm32port->gpios, UART_GPIO_RTS)) { in stm32_usart_init_port()
1545 clk_disable_unprepare(stm32port->clk); in stm32_usart_init_port()
1588 static void stm32_usart_of_dma_rx_remove(struct stm32_port *stm32port, in stm32_usart_of_dma_rx_remove() argument
1591 if (stm32port->rx_buf) in stm32_usart_of_dma_rx_remove()
1592 dma_free_coherent(&pdev->dev, RX_BUF_L, stm32port->rx_buf, in stm32_usart_of_dma_rx_remove()
1593 stm32port->rx_dma_buf); in stm32_usart_of_dma_rx_remove()
1596 static int stm32_usart_of_dma_rx_probe(struct stm32_port *stm32port, in stm32_usart_of_dma_rx_probe() argument
1599 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_of_dma_rx_probe()
1600 struct uart_port *port = &stm32port->port; in stm32_usart_of_dma_rx_probe()
1612 stm32port->rx_buf = dma_alloc_coherent(dev, RX_BUF_L, in stm32_usart_of_dma_rx_probe()
1613 &stm32port->rx_dma_buf, in stm32_usart_of_dma_rx_probe()
1615 if (!stm32port->rx_buf) in stm32_usart_of_dma_rx_probe()
1623 ret = dmaengine_slave_config(stm32port->rx_ch, &config); in stm32_usart_of_dma_rx_probe()
1626 stm32_usart_of_dma_rx_remove(stm32port, pdev); in stm32_usart_of_dma_rx_probe()
1633 static void stm32_usart_of_dma_tx_remove(struct stm32_port *stm32port, in stm32_usart_of_dma_tx_remove() argument
1636 if (stm32port->tx_buf) in stm32_usart_of_dma_tx_remove()
1637 dma_free_coherent(&pdev->dev, TX_BUF_L, stm32port->tx_buf, in stm32_usart_of_dma_tx_remove()
1638 stm32port->tx_dma_buf); in stm32_usart_of_dma_tx_remove()
1641 static int stm32_usart_of_dma_tx_probe(struct stm32_port *stm32port, in stm32_usart_of_dma_tx_probe() argument
1644 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; in stm32_usart_of_dma_tx_probe()
1645 struct uart_port *port = &stm32port->port; in stm32_usart_of_dma_tx_probe()
1650 stm32port->tx_buf = dma_alloc_coherent(dev, TX_BUF_L, in stm32_usart_of_dma_tx_probe()
1651 &stm32port->tx_dma_buf, in stm32_usart_of_dma_tx_probe()
1653 if (!stm32port->tx_buf) in stm32_usart_of_dma_tx_probe()
1661 ret = dmaengine_slave_config(stm32port->tx_ch, &config); in stm32_usart_of_dma_tx_probe()
1664 stm32_usart_of_dma_tx_remove(stm32port, pdev); in stm32_usart_of_dma_tx_probe()
1673 struct stm32_port *stm32port; in stm32_usart_serial_probe() local
1676 stm32port = stm32_usart_of_get_port(pdev); in stm32_usart_serial_probe()
1677 if (!stm32port) in stm32_usart_serial_probe()
1680 stm32port->info = of_device_get_match_data(&pdev->dev); in stm32_usart_serial_probe()
1681 if (!stm32port->info) in stm32_usart_serial_probe()
1684 ret = stm32_usart_init_port(stm32port, pdev); in stm32_usart_serial_probe()
1688 if (stm32port->wakeup_src) { in stm32_usart_serial_probe()
1690 ret = dev_pm_set_wake_irq(&pdev->dev, stm32port->port.irq); in stm32_usart_serial_probe()
1695 stm32port->rx_ch = dma_request_chan(&pdev->dev, "rx"); in stm32_usart_serial_probe()
1696 if (PTR_ERR(stm32port->rx_ch) == -EPROBE_DEFER) { in stm32_usart_serial_probe()
1701 if (IS_ERR(stm32port->rx_ch)) in stm32_usart_serial_probe()
1702 stm32port->rx_ch = NULL; in stm32_usart_serial_probe()
1704 stm32port->tx_ch = dma_request_chan(&pdev->dev, "tx"); in stm32_usart_serial_probe()
1705 if (PTR_ERR(stm32port->tx_ch) == -EPROBE_DEFER) { in stm32_usart_serial_probe()
1710 if (IS_ERR(stm32port->tx_ch)) in stm32_usart_serial_probe()
1711 stm32port->tx_ch = NULL; in stm32_usart_serial_probe()
1713 if (stm32port->rx_ch && stm32_usart_of_dma_rx_probe(stm32port, pdev)) { in stm32_usart_serial_probe()
1715 dma_release_channel(stm32port->rx_ch); in stm32_usart_serial_probe()
1716 stm32port->rx_ch = NULL; in stm32_usart_serial_probe()
1719 if (stm32port->tx_ch && stm32_usart_of_dma_tx_probe(stm32port, pdev)) { in stm32_usart_serial_probe()
1721 dma_release_channel(stm32port->tx_ch); in stm32_usart_serial_probe()
1722 stm32port->tx_ch = NULL; in stm32_usart_serial_probe()
1725 if (!stm32port->rx_ch) in stm32_usart_serial_probe()
1727 if (!stm32port->tx_ch) in stm32_usart_serial_probe()
1730 platform_set_drvdata(pdev, &stm32port->port); in stm32_usart_serial_probe()
1736 ret = uart_add_one_port(&stm32_usart_driver, &stm32port->port); in stm32_usart_serial_probe()
1749 if (stm32port->tx_ch) { in stm32_usart_serial_probe()
1750 stm32_usart_of_dma_tx_remove(stm32port, pdev); in stm32_usart_serial_probe()
1751 dma_release_channel(stm32port->tx_ch); in stm32_usart_serial_probe()
1754 if (stm32port->rx_ch) in stm32_usart_serial_probe()
1755 stm32_usart_of_dma_rx_remove(stm32port, pdev); in stm32_usart_serial_probe()
1758 if (stm32port->rx_ch) in stm32_usart_serial_probe()
1759 dma_release_channel(stm32port->rx_ch); in stm32_usart_serial_probe()
1762 if (stm32port->wakeup_src) in stm32_usart_serial_probe()
1766 if (stm32port->wakeup_src) in stm32_usart_serial_probe()
1769 stm32_usart_deinit_port(stm32port); in stm32_usart_serial_probe()
1871 struct stm32_port *stm32port; in stm32_usart_console_setup() local
1880 stm32port = &stm32_ports[co->index]; in stm32_usart_console_setup()
1888 if (stm32port->port.mapbase == 0 || !stm32port->port.membase) in stm32_usart_console_setup()
1894 return uart_set_options(&stm32port->port, co, baud, parity, bits, flow); in stm32_usart_console_setup()
2076 struct stm32_port *stm32port = container_of(port, in stm32_usart_runtime_suspend() local
2079 clk_disable_unprepare(stm32port->clk); in stm32_usart_runtime_suspend()
2087 struct stm32_port *stm32port = container_of(port, in stm32_usart_runtime_resume() local
2090 return clk_prepare_enable(stm32port->clk); in stm32_usart_runtime_resume()