Skip to content

Commit

Permalink
serial: stm32: fix wakeup source initialization
Browse files Browse the repository at this point in the history
[ Upstream commit 5297f274e8b61ceb9676cba6649d3de9d03387ad ]

Fixes dedicated_irq_wakeup issue and deactivated uart as wakeup source by
default.

Fixes: 270e5a7 ("serial: stm32: add wakeup mechanism")
Signed-off-by: Erwan Le Ray <erwan.leray@st.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Erwan Le Ray authored and GiovanYCringe committed May 17, 2023
1 parent 93c1d66 commit 45bf1ea
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions drivers/tty/serial/stm32-usart.c
Expand Up @@ -447,7 +447,6 @@ static int stm32_startup(struct uart_port *port)
{
struct stm32_port *stm32_port = to_stm32_port(port);
struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
struct stm32_usart_config *cfg = &stm32_port->info->cfg;
const char *name = to_platform_device(port->dev)->name;
u32 val;
int ret;
Expand All @@ -458,15 +457,6 @@ static int stm32_startup(struct uart_port *port)
if (ret)
return ret;

if (cfg->has_wakeup && stm32_port->wakeirq >= 0) {
ret = dev_pm_set_dedicated_wake_irq(port->dev,
stm32_port->wakeirq);
if (ret) {
free_irq(port->irq, port);
return ret;
}
}

val = USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE;
if (stm32_port->fifoen)
val |= USART_CR1_FIFOEN;
Expand Down Expand Up @@ -497,7 +487,6 @@ static void stm32_shutdown(struct uart_port *port)

stm32_clr_bits(port, ofs->cr1, val);

dev_pm_clear_wake_irq(port->dev);
free_irq(port->irq, port);
}

Expand Down Expand Up @@ -904,11 +893,18 @@ static int stm32_serial_probe(struct platform_device *pdev)
ret = device_init_wakeup(&pdev->dev, true);
if (ret)
goto err_uninit;

ret = dev_pm_set_dedicated_wake_irq(&pdev->dev,
stm32port->wakeirq);
if (ret)
goto err_nowup;

device_set_wakeup_enable(&pdev->dev, false);
}

ret = uart_add_one_port(&stm32_usart_driver, &stm32port->port);
if (ret)
goto err_nowup;
goto err_wirq;

ret = stm32_of_dma_rx_probe(stm32port, pdev);
if (ret)
Expand All @@ -922,6 +918,10 @@ static int stm32_serial_probe(struct platform_device *pdev)

return 0;

err_wirq:
if (stm32port->info->cfg.has_wakeup && stm32port->wakeirq >= 0)
dev_pm_clear_wake_irq(&pdev->dev);

err_nowup:
if (stm32port->info->cfg.has_wakeup && stm32port->wakeirq >= 0)
device_init_wakeup(&pdev->dev, false);
Expand Down Expand Up @@ -959,8 +959,10 @@ static int stm32_serial_remove(struct platform_device *pdev)
TX_BUF_L, stm32_port->tx_buf,
stm32_port->tx_dma_buf);

if (cfg->has_wakeup && stm32_port->wakeirq >= 0)
if (cfg->has_wakeup && stm32_port->wakeirq >= 0) {
dev_pm_clear_wake_irq(&pdev->dev);
device_init_wakeup(&pdev->dev, false);
}

clk_disable_unprepare(stm32_port->clk);

Expand Down

0 comments on commit 45bf1ea

Please sign in to comment.