mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 07:22:33 +00:00
53 lines
1.7 KiB
Diff
53 lines
1.7 KiB
Diff
|
From 558ca1294aa2bf7f29d55361d2f18c6dc534e1d6 Mon Sep 17 00:00:00 2001
|
||
|
From: Biwen Li <biwen.li@nxp.com>
|
||
|
Date: Tue, 30 Oct 2018 18:28:33 +0800
|
||
|
Subject: [PATCH 39/40] uart: support layerscape
|
||
|
This is an integrated patch of uart for layerscape
|
||
|
|
||
|
Signed-off-by: Sriram Dash <Sriram.dash@nxp.com>
|
||
|
Signed-off-by: Yuan Yao <yao.yuan@nxp.com>
|
||
|
Signed-off-by: Biwen Li <biwen.li@nxp.com>
|
||
|
---
|
||
|
drivers/tty/serial/fsl_lpuart.c | 15 +++++++++------
|
||
|
1 file changed, 9 insertions(+), 6 deletions(-)
|
||
|
|
||
|
--- a/drivers/tty/serial/fsl_lpuart.c
|
||
|
+++ b/drivers/tty/serial/fsl_lpuart.c
|
||
|
@@ -236,6 +236,8 @@
|
||
|
/* IMX lpuart has four extra unused regs located at the beginning */
|
||
|
#define IMX_REG_OFF 0x10
|
||
|
|
||
|
+static DECLARE_BITMAP(linemap, UART_NR);
|
||
|
+
|
||
|
struct lpuart_port {
|
||
|
struct uart_port port;
|
||
|
struct clk *clk;
|
||
|
@@ -2149,13 +2151,13 @@ static int lpuart_probe(struct platform_
|
||
|
|
||
|
ret = of_alias_get_id(np, "serial");
|
||
|
if (ret < 0) {
|
||
|
- dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
|
||
|
- return ret;
|
||
|
- }
|
||
|
- if (ret >= ARRAY_SIZE(lpuart_ports)) {
|
||
|
- dev_err(&pdev->dev, "serial%d out of range\n", ret);
|
||
|
- return -EINVAL;
|
||
|
+ ret = find_first_zero_bit(linemap, UART_NR);
|
||
|
+ if (ret >= UART_NR) {
|
||
|
+ dev_err(&pdev->dev, "port line is full, add device failed\n");
|
||
|
+ return ret;
|
||
|
+ }
|
||
|
}
|
||
|
+ set_bit(ret, linemap);
|
||
|
sport->port.line = ret;
|
||
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||
|
sport->port.membase = devm_ioremap_resource(&pdev->dev, res);
|
||
|
@@ -2246,6 +2248,7 @@ static int lpuart_remove(struct platform
|
||
|
struct lpuart_port *sport = platform_get_drvdata(pdev);
|
||
|
|
||
|
uart_remove_one_port(&lpuart_reg, &sport->port);
|
||
|
+ clear_bit(sport->port.line, linemap);
|
||
|
|
||
|
clk_disable_unprepare(sport->clk);
|
||
|
|