Skip to content

Commit

Permalink
serial: stm32: fix wakeup source initialization
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Erwan Le Ray authored and Greg Kroah-Hartman committed May 24, 2019
1 parent 64c32ea commit 5297f27
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions drivers/tty/serial/stm32-usart.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,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 @@ -568,15 +567,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 @@ -607,7 +597,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 @@ -1079,11 +1068,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 @@ -1097,6 +1093,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 @@ -1134,8 +1134,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 5297f27

Please sign in to comment.