1 From e8730a6bd02cf4f6a3e2d11585d91c0417ed92e5 Mon Sep 17 00:00:00 2001
2 From: Fugang Duan <fugang.duan@nxp.com>
3 Date: Wed, 10 Jul 2019 14:20:45 +0800
4 Subject: [PATCH] tty: serial: lpuart: add power domain support
6 lpuart dma mode depends on dma channel's power domain like:
7 power-domains = <&pd IMX_SC_R_UART_1>,
8 <&pd IMX_SC_R_DMA_2_CH10>,
9 <&pd IMX_SC_R_DMA_2_CH11>;
10 power-domain-names = "uart", "rxdma", "txdma";
12 So define the multiple power domain for lpuart.
14 Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
16 drivers/tty/serial/fsl_lpuart.c | 54 +++++++++++++++++++++++++++++++++++++++++
17 1 file changed, 54 insertions(+)
19 --- a/drivers/tty/serial/fsl_lpuart.c
20 +++ b/drivers/tty/serial/fsl_lpuart.c
23 #include <linux/of_device.h>
24 #include <linux/of_dma.h>
25 +#include <linux/pm_domain.h>
26 +#include <linux/pm_runtime.h>
27 #include <linux/serial_core.h>
28 #include <linux/slab.h>
29 #include <linux/tty_flip.h>
30 @@ -2394,6 +2396,54 @@ static struct uart_driver lpuart_reg = {
31 .cons = LPUART_CONSOLE,
34 +static int lpuart_attach_pd(struct device *dev)
36 + struct device *pd_uart;
37 + struct device *pd_txdma, *pd_rxdma;
38 + struct device_link *link;
43 + pd_uart = dev_pm_domain_attach_by_name(dev, "uart");
44 + if (IS_ERR(pd_uart))
45 + return PTR_ERR(pd_uart);
46 + link = device_link_add(dev, pd_uart, DL_FLAG_STATELESS |
47 + DL_FLAG_PM_RUNTIME |
48 + DL_FLAG_RPM_ACTIVE);
50 + dev_err(dev, "Failed to add device_link to uart pd: %ld\n",
52 + return PTR_ERR(link);
55 + pd_txdma = dev_pm_domain_attach_by_name(dev, "txdma");
56 + if (IS_ERR(pd_txdma))
57 + return PTR_ERR(pd_txdma);
58 + link = device_link_add(dev, pd_txdma, DL_FLAG_STATELESS |
59 + DL_FLAG_PM_RUNTIME |
60 + DL_FLAG_RPM_ACTIVE);
62 + dev_err(dev, "Failed to add device_link to uart pd: %ld\n",
64 + return PTR_ERR(link);
67 + pd_rxdma = dev_pm_domain_attach_by_name(dev, "rxdma");
68 + if (IS_ERR(pd_rxdma))
69 + return PTR_ERR(pd_rxdma);
70 + link = device_link_add(dev, pd_rxdma, DL_FLAG_STATELESS |
71 + DL_FLAG_PM_RUNTIME |
72 + DL_FLAG_RPM_ACTIVE);
74 + dev_err(dev, "Failed to add device_link to uart pd: %ld\n",
76 + return PTR_ERR(link);
82 static int lpuart_probe(struct platform_device *pdev)
84 const struct of_device_id *of_id = of_match_device(lpuart_dt_ids,
85 @@ -2431,6 +2481,10 @@ static int lpuart_probe(struct platform_
87 sport->port.rs485_config = lpuart_config_rs485;
89 + ret = lpuart_attach_pd(&pdev->dev);
93 sport->ipg_clk = devm_clk_get(&pdev->dev, "ipg");
94 if (IS_ERR(sport->ipg_clk)) {
95 ret = PTR_ERR(sport->ipg_clk);