* [PATCH AUTOSEL 5.0 23/98] sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()
From: Sasha Levin @ 2019-04-22 19:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Mao Wenan, Greg Kroah-Hartman, Sasha Levin, linux-serial
In-Reply-To: <20190422194205.10404-1-sashal@kernel.org>
From: Mao Wenan <maowenan@huawei.com>
[ Upstream commit ac0cdb3d990108df795b676cd0d0e65ac34b2273 ]
Add the missing uart_unregister_driver() and i2c_del_driver() before return
from sc16is7xx_init() in the error handling case.
Signed-off-by: Mao Wenan <maowenan@huawei.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/tty/serial/sc16is7xx.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 268098681856..114e94f476c6 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1509,7 +1509,7 @@ static int __init sc16is7xx_init(void)
ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver);
if (ret < 0) {
pr_err("failed to init sc16is7xx i2c --> %d\n", ret);
- return ret;
+ goto err_i2c;
}
#endif
@@ -1517,10 +1517,18 @@ static int __init sc16is7xx_init(void)
ret = spi_register_driver(&sc16is7xx_spi_uart_driver);
if (ret < 0) {
pr_err("failed to init sc16is7xx spi --> %d\n", ret);
- return ret;
+ goto err_spi;
}
#endif
return ret;
+
+err_spi:
+#ifdef CONFIG_SERIAL_SC16IS7XX_I2C
+ i2c_del_driver(&sc16is7xx_i2c_uart_driver);
+#endif
+err_i2c:
+ uart_unregister_driver(&sc16is7xx_uart);
+ return ret;
}
module_init(sc16is7xx_init);
--
2.19.1
^ permalink raw reply related
* [PATCH AUTOSEL 5.0 24/98] serial: ar933x_uart: Fix build failure with disabled console
From: Sasha Levin @ 2019-04-22 19:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Petr Štetiar, Greg Kroah-Hartman, Jiri Slaby, Andrey Batyiev,
Sasha Levin, linux-serial
In-Reply-To: <20190422194205.10404-1-sashal@kernel.org>
From: Petr Štetiar <ynezz@true.cz>
[ Upstream commit 72ff51d8dd262d1fef25baedc2ac35116435be47 ]
Andrey has reported on OpenWrt's bug tracking system[1], that he
currently can't use ar93xx_uart as pure serial UART without console
(CONFIG_SERIAL_8250_CONSOLE and CONFIG_SERIAL_AR933X_CONSOLE undefined),
because compilation ends with following error:
ar933x_uart.c: In function 'ar933x_uart_console_write':
ar933x_uart.c:550:14: error: 'struct uart_port' has no
member named 'sysrq'
So this patch moves all the code related to console handling behind
series of CONFIG_SERIAL_AR933X_CONSOLE ifdefs.
1. https://bugs.openwrt.org/index.php?do=details&task_id=2152
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Andrey Batyiev <batyiev@gmail.com>
Reported-by: Andrey Batyiev <batyiev@gmail.com>
Tested-by: Andrey Batyiev <batyiev@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/tty/serial/ar933x_uart.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index db5df3d54818..3bdd56a1021b 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -49,11 +49,6 @@ struct ar933x_uart_port {
struct clk *clk;
};
-static inline bool ar933x_uart_console_enabled(void)
-{
- return IS_ENABLED(CONFIG_SERIAL_AR933X_CONSOLE);
-}
-
static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up,
int offset)
{
@@ -508,6 +503,7 @@ static const struct uart_ops ar933x_uart_ops = {
.verify_port = ar933x_uart_verify_port,
};
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
static struct ar933x_uart_port *
ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS];
@@ -604,14 +600,7 @@ static struct console ar933x_uart_console = {
.index = -1,
.data = &ar933x_uart_driver,
};
-
-static void ar933x_uart_add_console_port(struct ar933x_uart_port *up)
-{
- if (!ar933x_uart_console_enabled())
- return;
-
- ar933x_console_ports[up->port.line] = up;
-}
+#endif /* CONFIG_SERIAL_AR933X_CONSOLE */
static struct uart_driver ar933x_uart_driver = {
.owner = THIS_MODULE,
@@ -700,7 +689,9 @@ static int ar933x_uart_probe(struct platform_device *pdev)
baud = ar933x_uart_get_baud(port->uartclk, 0, AR933X_UART_MAX_STEP);
up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD);
- ar933x_uart_add_console_port(up);
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
+ ar933x_console_ports[up->port.line] = up;
+#endif
ret = uart_add_one_port(&ar933x_uart_driver, &up->port);
if (ret)
@@ -749,8 +740,9 @@ static int __init ar933x_uart_init(void)
{
int ret;
- if (ar933x_uart_console_enabled())
- ar933x_uart_driver.cons = &ar933x_uart_console;
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
+ ar933x_uart_driver.cons = &ar933x_uart_console;
+#endif
ret = uart_register_driver(&ar933x_uart_driver);
if (ret)
--
2.19.1
^ permalink raw reply related
* [PATCH AUTOSEL 4.19 16/68] sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()
From: Sasha Levin @ 2019-04-22 19:44 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Mao Wenan, Greg Kroah-Hartman, Sasha Levin, linux-serial
In-Reply-To: <20190422194516.11634-1-sashal@kernel.org>
From: Mao Wenan <maowenan@huawei.com>
[ Upstream commit ac0cdb3d990108df795b676cd0d0e65ac34b2273 ]
Add the missing uart_unregister_driver() and i2c_del_driver() before return
from sc16is7xx_init() in the error handling case.
Signed-off-by: Mao Wenan <maowenan@huawei.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/tty/serial/sc16is7xx.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 47b41159a8bc..55b178c1bd65 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1481,7 +1481,7 @@ static int __init sc16is7xx_init(void)
ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver);
if (ret < 0) {
pr_err("failed to init sc16is7xx i2c --> %d\n", ret);
- return ret;
+ goto err_i2c;
}
#endif
@@ -1489,10 +1489,18 @@ static int __init sc16is7xx_init(void)
ret = spi_register_driver(&sc16is7xx_spi_uart_driver);
if (ret < 0) {
pr_err("failed to init sc16is7xx spi --> %d\n", ret);
- return ret;
+ goto err_spi;
}
#endif
return ret;
+
+err_spi:
+#ifdef CONFIG_SERIAL_SC16IS7XX_I2C
+ i2c_del_driver(&sc16is7xx_i2c_uart_driver);
+#endif
+err_i2c:
+ uart_unregister_driver(&sc16is7xx_uart);
+ return ret;
}
module_init(sc16is7xx_init);
--
2.19.1
^ permalink raw reply related
* [PATCH AUTOSEL 4.19 17/68] serial: ar933x_uart: Fix build failure with disabled console
From: Sasha Levin @ 2019-04-22 19:44 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Petr Štetiar, Greg Kroah-Hartman, Jiri Slaby, Andrey Batyiev,
Sasha Levin, linux-serial
In-Reply-To: <20190422194516.11634-1-sashal@kernel.org>
From: Petr Štetiar <ynezz@true.cz>
[ Upstream commit 72ff51d8dd262d1fef25baedc2ac35116435be47 ]
Andrey has reported on OpenWrt's bug tracking system[1], that he
currently can't use ar93xx_uart as pure serial UART without console
(CONFIG_SERIAL_8250_CONSOLE and CONFIG_SERIAL_AR933X_CONSOLE undefined),
because compilation ends with following error:
ar933x_uart.c: In function 'ar933x_uart_console_write':
ar933x_uart.c:550:14: error: 'struct uart_port' has no
member named 'sysrq'
So this patch moves all the code related to console handling behind
series of CONFIG_SERIAL_AR933X_CONSOLE ifdefs.
1. https://bugs.openwrt.org/index.php?do=details&task_id=2152
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Andrey Batyiev <batyiev@gmail.com>
Reported-by: Andrey Batyiev <batyiev@gmail.com>
Tested-by: Andrey Batyiev <batyiev@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/tty/serial/ar933x_uart.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index db5df3d54818..3bdd56a1021b 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -49,11 +49,6 @@ struct ar933x_uart_port {
struct clk *clk;
};
-static inline bool ar933x_uart_console_enabled(void)
-{
- return IS_ENABLED(CONFIG_SERIAL_AR933X_CONSOLE);
-}
-
static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up,
int offset)
{
@@ -508,6 +503,7 @@ static const struct uart_ops ar933x_uart_ops = {
.verify_port = ar933x_uart_verify_port,
};
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
static struct ar933x_uart_port *
ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS];
@@ -604,14 +600,7 @@ static struct console ar933x_uart_console = {
.index = -1,
.data = &ar933x_uart_driver,
};
-
-static void ar933x_uart_add_console_port(struct ar933x_uart_port *up)
-{
- if (!ar933x_uart_console_enabled())
- return;
-
- ar933x_console_ports[up->port.line] = up;
-}
+#endif /* CONFIG_SERIAL_AR933X_CONSOLE */
static struct uart_driver ar933x_uart_driver = {
.owner = THIS_MODULE,
@@ -700,7 +689,9 @@ static int ar933x_uart_probe(struct platform_device *pdev)
baud = ar933x_uart_get_baud(port->uartclk, 0, AR933X_UART_MAX_STEP);
up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD);
- ar933x_uart_add_console_port(up);
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
+ ar933x_console_ports[up->port.line] = up;
+#endif
ret = uart_add_one_port(&ar933x_uart_driver, &up->port);
if (ret)
@@ -749,8 +740,9 @@ static int __init ar933x_uart_init(void)
{
int ret;
- if (ar933x_uart_console_enabled())
- ar933x_uart_driver.cons = &ar933x_uart_console;
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
+ ar933x_uart_driver.cons = &ar933x_uart_console;
+#endif
ret = uart_register_driver(&ar933x_uart_driver);
if (ret)
--
2.19.1
^ permalink raw reply related
* [PATCH AUTOSEL 4.14 07/43] sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()
From: Sasha Levin @ 2019-04-22 19:46 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Mao Wenan, Greg Kroah-Hartman, Sasha Levin, linux-serial
In-Reply-To: <20190422194727.12495-1-sashal@kernel.org>
From: Mao Wenan <maowenan@huawei.com>
[ Upstream commit ac0cdb3d990108df795b676cd0d0e65ac34b2273 ]
Add the missing uart_unregister_driver() and i2c_del_driver() before return
from sc16is7xx_init() in the error handling case.
Signed-off-by: Mao Wenan <maowenan@huawei.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/tty/serial/sc16is7xx.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index a79f18edf2bd..e48523da47ac 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1483,7 +1483,7 @@ static int __init sc16is7xx_init(void)
ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver);
if (ret < 0) {
pr_err("failed to init sc16is7xx i2c --> %d\n", ret);
- return ret;
+ goto err_i2c;
}
#endif
@@ -1491,10 +1491,18 @@ static int __init sc16is7xx_init(void)
ret = spi_register_driver(&sc16is7xx_spi_uart_driver);
if (ret < 0) {
pr_err("failed to init sc16is7xx spi --> %d\n", ret);
- return ret;
+ goto err_spi;
}
#endif
return ret;
+
+err_spi:
+#ifdef CONFIG_SERIAL_SC16IS7XX_I2C
+ i2c_del_driver(&sc16is7xx_i2c_uart_driver);
+#endif
+err_i2c:
+ uart_unregister_driver(&sc16is7xx_uart);
+ return ret;
}
module_init(sc16is7xx_init);
--
2.19.1
^ permalink raw reply related
* [PATCH AUTOSEL 4.14 08/43] serial: ar933x_uart: Fix build failure with disabled console
From: Sasha Levin @ 2019-04-22 19:46 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Petr Štetiar, Greg Kroah-Hartman, Jiri Slaby, Andrey Batyiev,
Sasha Levin, linux-serial
In-Reply-To: <20190422194727.12495-1-sashal@kernel.org>
From: Petr Štetiar <ynezz@true.cz>
[ Upstream commit 72ff51d8dd262d1fef25baedc2ac35116435be47 ]
Andrey has reported on OpenWrt's bug tracking system[1], that he
currently can't use ar93xx_uart as pure serial UART without console
(CONFIG_SERIAL_8250_CONSOLE and CONFIG_SERIAL_AR933X_CONSOLE undefined),
because compilation ends with following error:
ar933x_uart.c: In function 'ar933x_uart_console_write':
ar933x_uart.c:550:14: error: 'struct uart_port' has no
member named 'sysrq'
So this patch moves all the code related to console handling behind
series of CONFIG_SERIAL_AR933X_CONSOLE ifdefs.
1. https://bugs.openwrt.org/index.php?do=details&task_id=2152
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Andrey Batyiev <batyiev@gmail.com>
Reported-by: Andrey Batyiev <batyiev@gmail.com>
Tested-by: Andrey Batyiev <batyiev@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/tty/serial/ar933x_uart.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index decc7f3c1ab2..ed545a61413c 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -52,11 +52,6 @@ struct ar933x_uart_port {
struct clk *clk;
};
-static inline bool ar933x_uart_console_enabled(void)
-{
- return IS_ENABLED(CONFIG_SERIAL_AR933X_CONSOLE);
-}
-
static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up,
int offset)
{
@@ -511,6 +506,7 @@ static const struct uart_ops ar933x_uart_ops = {
.verify_port = ar933x_uart_verify_port,
};
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
static struct ar933x_uart_port *
ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS];
@@ -607,14 +603,7 @@ static struct console ar933x_uart_console = {
.index = -1,
.data = &ar933x_uart_driver,
};
-
-static void ar933x_uart_add_console_port(struct ar933x_uart_port *up)
-{
- if (!ar933x_uart_console_enabled())
- return;
-
- ar933x_console_ports[up->port.line] = up;
-}
+#endif /* CONFIG_SERIAL_AR933X_CONSOLE */
static struct uart_driver ar933x_uart_driver = {
.owner = THIS_MODULE,
@@ -703,7 +692,9 @@ static int ar933x_uart_probe(struct platform_device *pdev)
baud = ar933x_uart_get_baud(port->uartclk, 0, AR933X_UART_MAX_STEP);
up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD);
- ar933x_uart_add_console_port(up);
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
+ ar933x_console_ports[up->port.line] = up;
+#endif
ret = uart_add_one_port(&ar933x_uart_driver, &up->port);
if (ret)
@@ -752,8 +743,9 @@ static int __init ar933x_uart_init(void)
{
int ret;
- if (ar933x_uart_console_enabled())
- ar933x_uart_driver.cons = &ar933x_uart_console;
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
+ ar933x_uart_driver.cons = &ar933x_uart_console;
+#endif
ret = uart_register_driver(&ar933x_uart_driver);
if (ret)
--
2.19.1
^ permalink raw reply related
* [PATCH AUTOSEL 4.9 06/29] sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()
From: Sasha Levin @ 2019-04-22 19:48 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Mao Wenan, Greg Kroah-Hartman, Sasha Levin, linux-serial
In-Reply-To: <20190422194848.13049-1-sashal@kernel.org>
From: Mao Wenan <maowenan@huawei.com>
[ Upstream commit ac0cdb3d990108df795b676cd0d0e65ac34b2273 ]
Add the missing uart_unregister_driver() and i2c_del_driver() before return
from sc16is7xx_init() in the error handling case.
Signed-off-by: Mao Wenan <maowenan@huawei.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/tty/serial/sc16is7xx.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index ea6b62cece88..82451bb6622b 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1482,7 +1482,7 @@ static int __init sc16is7xx_init(void)
ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver);
if (ret < 0) {
pr_err("failed to init sc16is7xx i2c --> %d\n", ret);
- return ret;
+ goto err_i2c;
}
#endif
@@ -1490,10 +1490,18 @@ static int __init sc16is7xx_init(void)
ret = spi_register_driver(&sc16is7xx_spi_uart_driver);
if (ret < 0) {
pr_err("failed to init sc16is7xx spi --> %d\n", ret);
- return ret;
+ goto err_spi;
}
#endif
return ret;
+
+err_spi:
+#ifdef CONFIG_SERIAL_SC16IS7XX_I2C
+ i2c_del_driver(&sc16is7xx_i2c_uart_driver);
+#endif
+err_i2c:
+ uart_unregister_driver(&sc16is7xx_uart);
+ return ret;
}
module_init(sc16is7xx_init);
--
2.19.1
^ permalink raw reply related
* [PATCH AUTOSEL 4.9 07/29] serial: ar933x_uart: Fix build failure with disabled console
From: Sasha Levin @ 2019-04-22 19:48 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Petr Štetiar, Greg Kroah-Hartman, Jiri Slaby, Andrey Batyiev,
Sasha Levin, linux-serial
In-Reply-To: <20190422194848.13049-1-sashal@kernel.org>
From: Petr Štetiar <ynezz@true.cz>
[ Upstream commit 72ff51d8dd262d1fef25baedc2ac35116435be47 ]
Andrey has reported on OpenWrt's bug tracking system[1], that he
currently can't use ar93xx_uart as pure serial UART without console
(CONFIG_SERIAL_8250_CONSOLE and CONFIG_SERIAL_AR933X_CONSOLE undefined),
because compilation ends with following error:
ar933x_uart.c: In function 'ar933x_uart_console_write':
ar933x_uart.c:550:14: error: 'struct uart_port' has no
member named 'sysrq'
So this patch moves all the code related to console handling behind
series of CONFIG_SERIAL_AR933X_CONSOLE ifdefs.
1. https://bugs.openwrt.org/index.php?do=details&task_id=2152
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Andrey Batyiev <batyiev@gmail.com>
Reported-by: Andrey Batyiev <batyiev@gmail.com>
Tested-by: Andrey Batyiev <batyiev@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/tty/serial/ar933x_uart.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index 73137f4aac20..d4462512605b 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -52,11 +52,6 @@ struct ar933x_uart_port {
struct clk *clk;
};
-static inline bool ar933x_uart_console_enabled(void)
-{
- return IS_ENABLED(CONFIG_SERIAL_AR933X_CONSOLE);
-}
-
static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up,
int offset)
{
@@ -511,6 +506,7 @@ static struct uart_ops ar933x_uart_ops = {
.verify_port = ar933x_uart_verify_port,
};
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
static struct ar933x_uart_port *
ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS];
@@ -607,14 +603,7 @@ static struct console ar933x_uart_console = {
.index = -1,
.data = &ar933x_uart_driver,
};
-
-static void ar933x_uart_add_console_port(struct ar933x_uart_port *up)
-{
- if (!ar933x_uart_console_enabled())
- return;
-
- ar933x_console_ports[up->port.line] = up;
-}
+#endif /* CONFIG_SERIAL_AR933X_CONSOLE */
static struct uart_driver ar933x_uart_driver = {
.owner = THIS_MODULE,
@@ -703,7 +692,9 @@ static int ar933x_uart_probe(struct platform_device *pdev)
baud = ar933x_uart_get_baud(port->uartclk, 0, AR933X_UART_MAX_STEP);
up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD);
- ar933x_uart_add_console_port(up);
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
+ ar933x_console_ports[up->port.line] = up;
+#endif
ret = uart_add_one_port(&ar933x_uart_driver, &up->port);
if (ret)
@@ -752,8 +743,9 @@ static int __init ar933x_uart_init(void)
{
int ret;
- if (ar933x_uart_console_enabled())
- ar933x_uart_driver.cons = &ar933x_uart_console;
+#ifdef CONFIG_SERIAL_AR933X_CONSOLE
+ ar933x_uart_driver.cons = &ar933x_uart_console;
+#endif
ret = uart_register_driver(&ar933x_uart_driver);
if (ret)
--
2.19.1
^ permalink raw reply related
* [PATCH AUTOSEL 4.4 03/21] sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()
From: Sasha Levin @ 2019-04-22 19:49 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Mao Wenan, Greg Kroah-Hartman, Sasha Levin, linux-serial
In-Reply-To: <20190422194941.13433-1-sashal@kernel.org>
From: Mao Wenan <maowenan@huawei.com>
[ Upstream commit ac0cdb3d990108df795b676cd0d0e65ac34b2273 ]
Add the missing uart_unregister_driver() and i2c_del_driver() before return
from sc16is7xx_init() in the error handling case.
Signed-off-by: Mao Wenan <maowenan@huawei.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/tty/serial/sc16is7xx.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 17a22073d226..032f3c13b8c4 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1448,7 +1448,7 @@ static int __init sc16is7xx_init(void)
ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver);
if (ret < 0) {
pr_err("failed to init sc16is7xx i2c --> %d\n", ret);
- return ret;
+ goto err_i2c;
}
#endif
@@ -1456,10 +1456,18 @@ static int __init sc16is7xx_init(void)
ret = spi_register_driver(&sc16is7xx_spi_uart_driver);
if (ret < 0) {
pr_err("failed to init sc16is7xx spi --> %d\n", ret);
- return ret;
+ goto err_spi;
}
#endif
return ret;
+
+err_spi:
+#ifdef CONFIG_SERIAL_SC16IS7XX_I2C
+ i2c_del_driver(&sc16is7xx_i2c_uart_driver);
+#endif
+err_i2c:
+ uart_unregister_driver(&sc16is7xx_uart);
+ return ret;
}
module_init(sc16is7xx_init);
--
2.19.1
^ permalink raw reply related
* Testing the recent RISC-V DT patchsets
From: Paul Walmsley @ 2019-04-23 0:17 UTC (permalink / raw)
To: linux-riscv, linux-serial, linux-kernel; +Cc: khilman
I've heard from two separate people who have had trouble getting started
with BBL & open-source FSBL test flows with arbitrary DT files on the
Freedom Unleashed board. The following instructions should help get
people started.
The core issue, aside from general unfamiliarity, is that multiple parts
of the pre-kernel software stack try to parse and/or modify the kernel DT.
We wish to avoid this as much as possible.
Testing with U-boot and OpenSBI is currently left as an exercise for the
reader, for a similar reason and because those ports are still quite new.
The following instructions are provided with no warranty whatsoever, and
assume knowledge of the shell and Linux. If implemented carelessly, may
trash your filesystems or do other horrible things.
- Paul
These instructions assume that bare metal and Linux RV64 cross-toolchains
are installed. If not, consider using crosstool-ng with the
"riscv64-unknown-elf" and "riscv64-unknown-linux-gnu" experimental sample
configurations. You will need both.
1. Put the location of the temporary build tree into the BASE
environment variable, and set up some initial directories:
export BASE=~/riscv-test; mkdir -p ${BASE}/work
2. Partition a microSD card with (at least) two GPT partitions.
Here is a sample sfdisk dump:
label: gpt
label-id: 074689DB-0440-411C-91DB-440DFE5BA0B6
device: /dev/sda
unit: sectors
first-lba: 34
last-lba: 62333918
/dev/sda1 : start= 2048, size= 2048, type=5B193300-FC78-40CD-8002-E86C45580B47, uuid=DEAD9378-45FF-44FB-B2E3-F3FEA45ADC9E, name="fsbl"
/dev/sda2 : start= 4096, size= 65536, type=2E54B353-1271-4842-806F-E436D6AF6985, uuid=1B48DE68-8004-444D-BA47-AAA8DBEBFA60, name="bbl"
/dev/sda3 : start= 69632, size= 62264287, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=D672F1FC-3E45-4CC1-835A-E6384A26C395, name="rootfs"
3. Download the open-source FSBL:
cd ${BASE}
git clone https://github.com/sifive/freedom-u540-c000-bootloader
4. Build the open-source FSBL:
cd freedom-u540-c000-bootloader
CROSSCOMPILE=/opt/rv64gc-mmu-elf/bin/riscv64-unknown-elf- make
5. Write the open-source FSBL to the first partition of the SD card with
something like:
sudo dd if=fsbl.bin of=/dev/SD-CARD-DEVICE1 conv=nocreat
6. Copy an initramfs sysroot into ${BASE}/work/buildroot_initramfs_sysroot.
A reasonable one to start with is the sysroot built by
freedom-u-sdk, in work/buildroot_initramfs_sysroot.
7. Set the CROSS_COMPILE environment variable to point to your
cross-compiler, in the Linux kernel form:
export CROSS_COMPILE=/opt/rv64gc-mmu-linux-8.2.0/bin/riscv64-unknown-linux-gnu-
8. Put something like this into a script and run it:
if [ ! -d ${BASE} ]; then
echo Base build directory must be set in the BASE environment variable
fi
if [ ! -x ${CROSS_COMPILE}gcc ]; then
echo Path to cross-compiler must be set in the CROSS_COMPILE
environment variable
fi
export ARCH=riscv
export OBJCOPY=${CROSS_COMPILE}objcopy
export CC=${CROSS_COMPILE}gcc
CORES=$(getconf _NPROCESSORS_ONLN)
#
#
cd ${BASE}
git clone -b dev/paulw/reduce-dt-load-v1
https://github.com/sifive/riscv-pk
git clone -b dev/paulw/dts-v5.1-rc6-experimental
https://github.com/sifive/riscv-linux
cd riscv-linux
make -j${CORES} defconfig dtbs vmlinux
${CROSS_COMPILE}strip -o ${BASE}/work/vmlinux-stripped
${BASE}/riscv-linux/vmlinux
rm -rf ${BASE}/work/riscv-pk
mkdir -p ${BASE}/work/riscv-pk
cd ${BASE}/work/riscv-pk
ln -sf
${BASE}/riscv-linux/arch/riscv/boot/dts/sifive/hifive-unleashed-a00-fu540.dtb
${BASE}/riscv-pk/linux.dtb
${BASE}/riscv-pk/configure \
--host=riscv64-unknown-linux-gnu \
--enable-print-device-tree --with-payload=../vmlinux-stripped
CFLAGS="-mabi=lp64d -march=rv64imafdc" make
$OBJCOPY -S -O binary --change-addresses -0x80000000 bbl ../bbl.bin
9. Write ${BASE}/work/bbl.bin to the second partition of your microSD
card with something like:
sudo dd if=${BASE}/work/bbl.bin of=/dev/SD-CARD-DEVICE2 bs=64k conv=nocreat
10. Boot the microSD card on your Unleashed board.
^ permalink raw reply
* Re: [PATCH 15/24] dt-bindings: pinctrl: pinctrl-mt65xx: add support for MT8516
From: Linus Walleij @ 2019-04-23 11:01 UTC (permalink / raw)
To: Matthias Brugger
Cc: Fabien Parent, Rob Herring, Mark Rutland, Sean Wang, Ryder Lee,
hsin-hsiung.wang, wenzhen.yu, Chaotian Jing, Yong Mao, jjian.zhou,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
linux-kernel@vger.kernel.org, linux-i2c, Linux ARM,
moderated list:ARM/Mediatek SoC support, linux-mmc,
open list:GPIO SUBSYSTEM, linux-serial@
In-Reply-To: <b1e4eb6c-0d53-0307-99e4-9fef9e2b33d8@gmail.com>
On Tue, Apr 16, 2019 at 11:12 AM Matthias Brugger
<matthias.bgg@gmail.com> wrote:
> Hi Linus,
>
> On 08/04/2019 22:44, Linus Walleij wrote:
> > On Sat, Mar 23, 2019 at 10:17 PM Fabien Parent <fparent@baylibre.com> wrote:
> >
> >> Add binding documentation of pinctrl-mt65xx for MT8516 SoC.
> >>
> >> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> >
> > Patch applied with Rob's ACK.
> >
>
> I don't see this in your for-next branch. Did the patch got lost?
I usually push the devel branch to be tested by the build robots
and then mix down the for-next branch.
Recent week(s) the build robot was not responding so it got delayed.
Yours,
Linus Walleij
^ permalink raw reply
* Re: [PATCH 15/24] dt-bindings: pinctrl: pinctrl-mt65xx: add support for MT8516
From: Matthias Brugger @ 2019-04-23 14:24 UTC (permalink / raw)
To: Linus Walleij
Cc: Fabien Parent, Rob Herring, Mark Rutland, Sean Wang, Ryder Lee,
hsin-hsiung.wang, wenzhen.yu, Chaotian Jing, Yong Mao, jjian.zhou,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
linux-kernel@vger.kernel.org, linux-i2c, Linux ARM,
moderated list:ARM/Mediatek SoC support, linux-mmc,
open list:GPIO SUBSYSTEM, linux-serial@
In-Reply-To: <CACRpkdZ8gq+hGRT6EAyP2w9K0jz5RAzWeZ6_UrW+v-BOjd-wbg@mail.gmail.com>
On 23/04/2019 13:01, Linus Walleij wrote:
> On Tue, Apr 16, 2019 at 11:12 AM Matthias Brugger
> <matthias.bgg@gmail.com> wrote:
>
>> Hi Linus,
>>
>> On 08/04/2019 22:44, Linus Walleij wrote:
>>> On Sat, Mar 23, 2019 at 10:17 PM Fabien Parent <fparent@baylibre.com> wrote:
>>>
>>>> Add binding documentation of pinctrl-mt65xx for MT8516 SoC.
>>>>
>>>> Signed-off-by: Fabien Parent <fparent@baylibre.com>
>>>
>>> Patch applied with Rob's ACK.
>>>
>>
>> I don't see this in your for-next branch. Did the patch got lost?
>
> I usually push the devel branch to be tested by the build robots
> and then mix down the for-next branch.
>
> Recent week(s) the build robot was not responding so it got delayed.
>
I don't see it in the devel branch [1]. Can you please double check?
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=devel
^ permalink raw reply
* Re: [PATCH v5 0/2] tty: serial: add DT bindings and serial driver for the SiFive FU540 UART
From: Paul Walmsley @ 2019-04-24 18:58 UTC (permalink / raw)
To: Kevin Hilman
Cc: Atish Patra, Paul Walmsley, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, linux-riscv@lists.infradead.org,
gregkh@linuxfoundation.org
In-Reply-To: <7h5zr9dcsi.fsf@baylibre.com>
Hi Kevin,
On Fri, 19 Apr 2019, Kevin Hilman wrote:
> Atish Patra <atish.patra@wdc.com> writes:
> > On 4/18/19 4:22 PM, Kevin Hilman wrote:
> >> Paul Walmsley <paul.walmsley@sifive.com> writes:
> >>
> >>> This series adds a serial driver, with console support, for the
> >>> UART IP block present on the SiFive FU540 SoC. The programming
> >>> model is straightforward, but unique.
> >>>
> >>> Boot-tested on a SiFive FU540 HiFive-U board, using BBL and the
> >>> open-source FSBL (with appropriate patches to the DT data).
> >>>
> >>> This fifth version fixes a bug in the set_termios handler,
> >>> found by Andreas Schwab <schwab@suse.de>.
> >>>
> >>> The patches in this series can also be found, with the PRCI patches,
> >>> DT patches, and DT prerequisite patch, at:
> >>>
> >>> https://github.com/sifive/riscv-linux/tree/dev/paulw/serial-v5.1-rc4
...
> I've just updated to u-boot master branch with SMP enabled, and build a
> new openSBI (also from master branch) with u-boot payload. Using your
> v5.1-rc4_unleashed branch, I see 4 CPUs booting:
> https://termbin.com/kg13
Now that the serial driver is working for you, care to send a Tested-by: ?
thanks,
- Paul
^ permalink raw reply
* [PATCH 0/2] Perfect 8250 mtk uart function.
From: Long Cheng @ 2019-04-25 8:41 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Matthias Brugger, Long Cheng, Gustavo A. R. Silva,
Peter Shih, linux-serial, linux-arm-kernel, linux-mediatek,
linux-kernel, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu,
Changqi Hu
Perfect 8250 mtk uart function,
1.Modify baudrate setting
2.Add follow control function
Long Cheng (2):
serial: 8250-mtk: add follow control
serial: 8250-mtk: modify baudrate setting
drivers/tty/serial/8250/8250_mtk.c | 162 +++++++++++++++++++++++++++++++------
1 file changed, 139 insertions(+), 23 deletions(-)
--
1.9.1
^ permalink raw reply
* [PATCH 1/2] serial: 8250-mtk: add follow control
From: Long Cheng @ 2019-04-25 8:41 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Matthias Brugger, Long Cheng, Gustavo A. R. Silva,
Peter Shih, linux-serial, linux-arm-kernel, linux-mediatek,
linux-kernel, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu,
Changqi Hu
In-Reply-To: <1556181691-10293-1-git-send-email-long.cheng@mediatek.com>
Add SW and HW follow control function.
Signed-off-by: Long Cheng <long.cheng@mediatek.com>
---
drivers/tty/serial/8250/8250_mtk.c | 60 ++++++++++++++++++++++--------------
1 file changed, 37 insertions(+), 23 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index c1fdbc0..959fd85 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -21,12 +21,14 @@
#include "8250.h"
-#define UART_MTK_HIGHS 0x09 /* Highspeed register */
-#define UART_MTK_SAMPLE_COUNT 0x0a /* Sample count register */
-#define UART_MTK_SAMPLE_POINT 0x0b /* Sample point register */
+#define MTK_UART_HIGHS 0x09 /* Highspeed register */
+#define MTK_UART_SAMPLE_COUNT 0x0a /* Sample count register */
+#define MTK_UART_SAMPLE_POINT 0x0b /* Sample point register */
#define MTK_UART_RATE_FIX 0x0d /* UART Rate Fix Register */
-
#define MTK_UART_DMA_EN 0x13 /* DMA Enable register */
+#define MTK_UART_RXTRI_AD 0x14 /* RX Trigger address */
+#define MTK_UART_FRACDIV_L 0x15 /* Fractional divider LSB address */
+#define MTK_UART_FRACDIV_M 0x16 /* Fractional divider MSB address */
#define MTK_UART_DMA_EN_TX 0x2
#define MTK_UART_DMA_EN_RX 0x5
@@ -46,6 +48,7 @@ enum dma_rx_status {
struct mtk8250_data {
int line;
unsigned int rx_pos;
+ unsigned int clk_count;
struct clk *uart_clk;
struct clk *bus_clk;
struct uart_8250_dma *dma;
@@ -196,9 +199,15 @@ static void mtk8250_shutdown(struct uart_port *port)
mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
+ unsigned short fraction_L_mapping[] = {
+ 0, 1, 0x5, 0x15, 0x55, 0x57, 0x57, 0x77, 0x7F, 0xFF, 0xFF
+ };
+ unsigned short fraction_M_mapping[] = {
+ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 3
+ };
struct uart_8250_port *up = up_to_u8250p(port);
+ unsigned int baud, quot, fraction;
unsigned long flags;
- unsigned int baud, quot;
#ifdef CONFIG_SERIAL_8250_DMA
if (up->dma) {
@@ -214,7 +223,7 @@ static void mtk8250_shutdown(struct uart_port *port)
serial8250_do_set_termios(port, termios, old);
/*
- * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS)
+ * Mediatek UARTs use an extra highspeed register (MTK_UART_HIGHS)
*
* We need to recalcualte the quot register, as the claculation depends
* on the vaule in the highspeed register.
@@ -230,18 +239,11 @@ static void mtk8250_shutdown(struct uart_port *port)
port->uartclk / 16 / UART_DIV_MAX,
port->uartclk);
- if (baud <= 115200) {
- serial_port_out(port, UART_MTK_HIGHS, 0x0);
+ if (baud < 115200) {
+ serial_port_out(port, MTK_UART_HIGHS, 0x0);
quot = uart_get_divisor(port, baud);
- } else if (baud <= 576000) {
- serial_port_out(port, UART_MTK_HIGHS, 0x2);
-
- /* Set to next lower baudrate supported */
- if ((baud == 500000) || (baud == 576000))
- baud = 460800;
- quot = DIV_ROUND_UP(port->uartclk, 4 * baud);
} else {
- serial_port_out(port, UART_MTK_HIGHS, 0x3);
+ serial_port_out(port, MTK_UART_HIGHS, 0x3);
quot = DIV_ROUND_UP(port->uartclk, 256 * baud);
}
@@ -258,17 +260,29 @@ static void mtk8250_shutdown(struct uart_port *port)
/* reset DLAB */
serial_port_out(port, UART_LCR, up->lcr);
- if (baud > 460800) {
+ if (baud >= 115200) {
unsigned int tmp;
- tmp = DIV_ROUND_CLOSEST(port->uartclk, quot * baud);
- serial_port_out(port, UART_MTK_SAMPLE_COUNT, tmp - 1);
- serial_port_out(port, UART_MTK_SAMPLE_POINT,
- (tmp - 2) >> 1);
+ tmp = (port->uartclk / (baud * quot)) - 1;
+ serial_port_out(port, MTK_UART_SAMPLE_COUNT, tmp);
+ serial_port_out(port, MTK_UART_SAMPLE_POINT,
+ (tmp >> 1) - 1);
+
+ /*count fraction to set fractoin register */
+ fraction = ((port->uartclk * 100) / baud / quot) % 100;
+ fraction = DIV_ROUND_CLOSEST(fraction, 10);
+ serial_port_out(port, MTK_UART_FRACDIV_L,
+ fraction_L_mapping[fraction]);
+ serial_port_out(port, MTK_UART_FRACDIV_M,
+ fraction_M_mapping[fraction]);
} else {
- serial_port_out(port, UART_MTK_SAMPLE_COUNT, 0x00);
- serial_port_out(port, UART_MTK_SAMPLE_POINT, 0xff);
+ serial_port_out(port, MTK_UART_SAMPLE_COUNT, 0x00);
+ serial_port_out(port, MTK_UART_SAMPLE_POINT, 0xff);
+ serial_port_out(port, MTK_UART_FRACDIV_L, 0x00);
+ serial_port_out(port, MTK_UART_FRACDIV_M, 0x00);
}
+ if (uart_console(port))
+ up->port.cons->cflag = termios->c_cflag;
spin_unlock_irqrestore(&port->lock, flags);
/* Don't rewrite B0 */
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/2] serial: 8250-mtk: modify baudrate setting
From: Long Cheng @ 2019-04-25 8:41 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Matthias Brugger, Long Cheng, Gustavo A. R. Silva,
Peter Shih, linux-serial, linux-arm-kernel, linux-mediatek,
linux-kernel, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu,
Changqi Hu
In-Reply-To: <1556181691-10293-1-git-send-email-long.cheng@mediatek.com>
In termios function, add Fractional divider to adjust baudrate.
Signed-off-by: Long Cheng <long.cheng@mediatek.com>
---
drivers/tty/serial/8250/8250_mtk.c | 102 ++++++++++++++++++++++++++++++++++++
1 file changed, 102 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index 959fd85..417c7c8 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -25,13 +25,28 @@
#define MTK_UART_SAMPLE_COUNT 0x0a /* Sample count register */
#define MTK_UART_SAMPLE_POINT 0x0b /* Sample point register */
#define MTK_UART_RATE_FIX 0x0d /* UART Rate Fix Register */
+#define MTK_UART_ESCAPE_DAT 0x10 /* Escape Character register */
+#define MTK_UART_ESCAPE_EN 0x11 /* Escape Enable register */
#define MTK_UART_DMA_EN 0x13 /* DMA Enable register */
#define MTK_UART_RXTRI_AD 0x14 /* RX Trigger address */
#define MTK_UART_FRACDIV_L 0x15 /* Fractional divider LSB address */
#define MTK_UART_FRACDIV_M 0x16 /* Fractional divider MSB address */
+#define MTK_UART_IER_XOFFI 0x20 /* Enable XOFF character interrupt */
+#define MTK_UART_IER_RTSI 0x40 /* Enable RTS Modem status interrupt */
+#define MTK_UART_IER_CTSI 0x80 /* Enable CTS Modem status interrupt */
+
+#define MTK_UART_EFR_EN 0x10 /* Enable enhancement feature */
+#define MTK_UART_EFR_RTS 0x40 /* Enable hardware rx flow control */
+#define MTK_UART_EFR_CTS 0x80 /* Enable hardware tx flow control */
+#define MTK_UART_EFR_NO_SW_FC 0x0 /* no sw flow control */
+#define MTK_UART_EFR_XON1_XOFF1 0xa /* XON1/XOFF1 as sw flow control */
+#define MTK_UART_EFR_XON2_XOFF2 0x5 /* XON2/XOFF2 as sw flow control */
+#define MTK_UART_EFR_SW_FC_MASK 0xf /* Enable CTS Modem status interrupt */
+#define MTK_UART_EFR_HW_FC (MTK_UART_EFR_RTS | MTK_UART_EFR_CTS)
#define MTK_UART_DMA_EN_TX 0x2
#define MTK_UART_DMA_EN_RX 0x5
+#define MTK_UART_ESCAPE_CHAR 0x77 /* Escape char added under sw fc */
#define MTK_UART_TX_SIZE UART_XMIT_SIZE
#define MTK_UART_RX_SIZE 0x8000
#define MTK_UART_TX_TRIGGER 1
@@ -57,6 +72,13 @@ struct mtk8250_data {
#endif
};
+/* flow control mode */
+enum {
+ MTK_UART_FC_NONE,
+ MTK_UART_FC_SW,
+ MTK_UART_FC_HW,
+};
+
#ifdef CONFIG_SERIAL_8250_DMA
static void mtk8250_rx_dma(struct uart_8250_port *up);
@@ -195,6 +217,75 @@ static void mtk8250_shutdown(struct uart_port *port)
return serial8250_do_shutdown(port);
}
+static void mtk8250_disable_intrs(struct uart_8250_port *up, int mask)
+{
+ serial_out(up, UART_IER, serial_in(up, UART_IER) & (~mask));
+}
+
+static void mtk8250_enable_intrs(struct uart_8250_port *up, int mask)
+{
+ serial_out(up, UART_IER, serial_in(up, UART_IER) | mask);
+}
+
+static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode)
+{
+ struct uart_port *port = &up->port;
+ int lcr = serial_in(up, UART_LCR);
+
+ serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
+ serial_out(up, UART_EFR, UART_EFR_ECB);
+ serial_out(up, UART_LCR, lcr);
+ lcr = serial_in(up, UART_LCR);
+
+ switch (mode) {
+ case MTK_UART_FC_NONE:
+ serial_out(up, MTK_UART_ESCAPE_DAT, MTK_UART_ESCAPE_CHAR);
+ serial_out(up, MTK_UART_ESCAPE_EN, 0x00);
+ serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
+ serial_out(up, UART_EFR, serial_in(up, UART_EFR) &
+ (~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK)));
+ serial_out(up, UART_LCR, lcr);
+ mtk8250_disable_intrs(up, MTK_UART_IER_XOFFI |
+ MTK_UART_IER_RTSI | MTK_UART_IER_CTSI);
+ break;
+
+ case MTK_UART_FC_HW:
+ serial_out(up, MTK_UART_ESCAPE_DAT, MTK_UART_ESCAPE_CHAR);
+ serial_out(up, MTK_UART_ESCAPE_EN, 0x00);
+ serial_out(up, UART_MCR, UART_MCR_RTS);
+ serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
+
+ /*enable hw flow control*/
+ serial_out(up, UART_EFR, MTK_UART_EFR_HW_FC |
+ (serial_in(up, UART_EFR) &
+ (~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK))));
+
+ serial_out(up, UART_LCR, lcr);
+ mtk8250_disable_intrs(up, MTK_UART_IER_XOFFI);
+ mtk8250_enable_intrs(up, MTK_UART_IER_CTSI | MTK_UART_IER_RTSI);
+ break;
+
+ case MTK_UART_FC_SW: /*MTK software flow control */
+ serial_out(up, MTK_UART_ESCAPE_DAT, MTK_UART_ESCAPE_CHAR);
+ serial_out(up, MTK_UART_ESCAPE_EN, 0x01);
+ serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
+
+ /*enable sw flow control */
+ serial_out(up, UART_EFR, MTK_UART_EFR_XON1_XOFF1 |
+ (serial_in(up, UART_EFR) &
+ (~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK))));
+
+ serial_out(up, UART_XON1, START_CHAR(port->state->port.tty));
+ serial_out(up, UART_XOFF1, STOP_CHAR(port->state->port.tty));
+ serial_out(up, UART_LCR, lcr);
+ mtk8250_disable_intrs(up, MTK_UART_IER_CTSI|MTK_UART_IER_RTSI);
+ mtk8250_enable_intrs(up, MTK_UART_IER_XOFFI);
+ break;
+ default:
+ break;
+ }
+}
+
static void
mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
@@ -208,6 +299,7 @@ static void mtk8250_shutdown(struct uart_port *port)
struct uart_8250_port *up = up_to_u8250p(port);
unsigned int baud, quot, fraction;
unsigned long flags;
+ int mode;
#ifdef CONFIG_SERIAL_8250_DMA
if (up->dma) {
@@ -281,6 +373,16 @@ static void mtk8250_shutdown(struct uart_port *port)
serial_port_out(port, MTK_UART_FRACDIV_L, 0x00);
serial_port_out(port, MTK_UART_FRACDIV_M, 0x00);
}
+
+ if ((termios->c_cflag & CRTSCTS) && (!(termios->c_iflag & CRTSCTS)))
+ mode = MTK_UART_FC_HW;
+ else if (termios->c_iflag & CRTSCTS)
+ mode = MTK_UART_FC_SW;
+ else
+ mode = MTK_UART_FC_NONE;
+
+ mtk8250_set_flow_ctrl(up, mode);
+
if (uart_console(port))
up->port.cons->cflag = termios->c_cflag;
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH 1/2] serial: 8250-mtk: add follow control
From: Matthias Brugger @ 2019-04-25 10:40 UTC (permalink / raw)
To: Long Cheng, Greg Kroah-Hartman
Cc: Jiri Slaby, Gustavo A. R. Silva, Peter Shih, linux-serial,
linux-arm-kernel, linux-mediatek, linux-kernel, srv_heupstream,
Yingjoe Chen, YT Shen, Zhenbao Liu, Changqi Hu
In-Reply-To: <1556181691-10293-2-git-send-email-long.cheng@mediatek.com>
On 25/04/2019 10:41, Long Cheng wrote:
> Add SW and HW follow control function.
Can you please explain a bit more what you are doing in this patch.
You change the setting of the registers for different baud rates. Please
elaborate what is happening there.
>
> Signed-off-by: Long Cheng <long.cheng@mediatek.com>
> ---
> drivers/tty/serial/8250/8250_mtk.c | 60 ++++++++++++++++++++++--------------
> 1 file changed, 37 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> index c1fdbc0..959fd85 100644
> --- a/drivers/tty/serial/8250/8250_mtk.c
> +++ b/drivers/tty/serial/8250/8250_mtk.c
> @@ -21,12 +21,14 @@
>
> #include "8250.h"
>
> -#define UART_MTK_HIGHS 0x09 /* Highspeed register */
> -#define UART_MTK_SAMPLE_COUNT 0x0a /* Sample count register */
> -#define UART_MTK_SAMPLE_POINT 0x0b /* Sample point register */
> +#define MTK_UART_HIGHS 0x09 /* Highspeed register */
> +#define MTK_UART_SAMPLE_COUNT 0x0a /* Sample count register */
> +#define MTK_UART_SAMPLE_POINT 0x0b /* Sample point register */
Rename looks good to me. But I'd prefer to have it in a separate patch.
> #define MTK_UART_RATE_FIX 0x0d /* UART Rate Fix Register */
> -
> #define MTK_UART_DMA_EN 0x13 /* DMA Enable register */
> +#define MTK_UART_RXTRI_AD 0x14 /* RX Trigger address */
> +#define MTK_UART_FRACDIV_L 0x15 /* Fractional divider LSB address */
> +#define MTK_UART_FRACDIV_M 0x16 /* Fractional divider MSB address */
> #define MTK_UART_DMA_EN_TX 0x2
> #define MTK_UART_DMA_EN_RX 0x5
>
> @@ -46,6 +48,7 @@ enum dma_rx_status {
> struct mtk8250_data {
> int line;
> unsigned int rx_pos;
> + unsigned int clk_count;
What is that for, not used in this patch.
> struct clk *uart_clk;
> struct clk *bus_clk;
> struct uart_8250_dma *dma;
> @@ -196,9 +199,15 @@ static void mtk8250_shutdown(struct uart_port *port)
> mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
> struct ktermios *old)
> {
> + unsigned short fraction_L_mapping[] = {
> + 0, 1, 0x5, 0x15, 0x55, 0x57, 0x57, 0x77, 0x7F, 0xFF, 0xFF
> + };
> + unsigned short fraction_M_mapping[] = {
> + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 3
> + };
> struct uart_8250_port *up = up_to_u8250p(port);
> + unsigned int baud, quot, fraction;
> unsigned long flags;
> - unsigned int baud, quot;
>
> #ifdef CONFIG_SERIAL_8250_DMA
> if (up->dma) {
> @@ -214,7 +223,7 @@ static void mtk8250_shutdown(struct uart_port *port)
> serial8250_do_set_termios(port, termios, old);
>
> /*
> - * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS)
> + * Mediatek UARTs use an extra highspeed register (MTK_UART_HIGHS)
> *
> * We need to recalcualte the quot register, as the claculation depends
> * on the vaule in the highspeed register.
> @@ -230,18 +239,11 @@ static void mtk8250_shutdown(struct uart_port *port)
> port->uartclk / 16 / UART_DIV_MAX,
> port->uartclk);
>
> - if (baud <= 115200) {
> - serial_port_out(port, UART_MTK_HIGHS, 0x0);
> + if (baud < 115200) {
> + serial_port_out(port, MTK_UART_HIGHS, 0x0);
> quot = uart_get_divisor(port, baud);
> - } else if (baud <= 576000) {
> - serial_port_out(port, UART_MTK_HIGHS, 0x2);
> -
> - /* Set to next lower baudrate supported */
> - if ((baud == 500000) || (baud == 576000))
> - baud = 460800;
> - quot = DIV_ROUND_UP(port->uartclk, 4 * baud);
So we allow now also these baud rates? Then you have to update the comment as well.
Regards,
Matthias
> } else {
> - serial_port_out(port, UART_MTK_HIGHS, 0x3);
> + serial_port_out(port, MTK_UART_HIGHS, 0x3);
> quot = DIV_ROUND_UP(port->uartclk, 256 * baud);
> }
>
> @@ -258,17 +260,29 @@ static void mtk8250_shutdown(struct uart_port *port)
> /* reset DLAB */
> serial_port_out(port, UART_LCR, up->lcr);
>
> - if (baud > 460800) {
> + if (baud >= 115200) {
> unsigned int tmp;
>
> - tmp = DIV_ROUND_CLOSEST(port->uartclk, quot * baud);
> - serial_port_out(port, UART_MTK_SAMPLE_COUNT, tmp - 1);
> - serial_port_out(port, UART_MTK_SAMPLE_POINT,
> - (tmp - 2) >> 1);
> + tmp = (port->uartclk / (baud * quot)) - 1;
> + serial_port_out(port, MTK_UART_SAMPLE_COUNT, tmp);
> + serial_port_out(port, MTK_UART_SAMPLE_POINT,
> + (tmp >> 1) - 1);
> +
> + /*count fraction to set fractoin register */
> + fraction = ((port->uartclk * 100) / baud / quot) % 100;
> + fraction = DIV_ROUND_CLOSEST(fraction, 10);
> + serial_port_out(port, MTK_UART_FRACDIV_L,
> + fraction_L_mapping[fraction]);
> + serial_port_out(port, MTK_UART_FRACDIV_M,
> + fraction_M_mapping[fraction]);
> } else {
> - serial_port_out(port, UART_MTK_SAMPLE_COUNT, 0x00);
> - serial_port_out(port, UART_MTK_SAMPLE_POINT, 0xff);
> + serial_port_out(port, MTK_UART_SAMPLE_COUNT, 0x00);
> + serial_port_out(port, MTK_UART_SAMPLE_POINT, 0xff);
> + serial_port_out(port, MTK_UART_FRACDIV_L, 0x00);
> + serial_port_out(port, MTK_UART_FRACDIV_M, 0x00);
> }
> + if (uart_console(port))
> + up->port.cons->cflag = termios->c_cflag;
>
> spin_unlock_irqrestore(&port->lock, flags);
> /* Don't rewrite B0 */
>
^ permalink raw reply
* Re: [PATCH 11/24] dt-bindings: mediatek: topckgen: add support for MT8516
From: Stephen Boyd @ 2019-04-25 21:34 UTC (permalink / raw)
To: mark.rutland, matthias.bgg, robh+dt
Cc: sean.wang, ryder.lee, hsin-hsiung.wang, wenzhen.yu, chaotian.jing,
yong.mao, jjian.zhou, devicetree, linux-kernel, linux-i2c,
linux-arm-kernel, linux-mediatek, linux-mmc, linux-gpio,
linux-serial, linux-spi, linux-watchdog, linux-clk,
stephane.leprovost, Fabien Parent
In-Reply-To: <20190323211612.860-12-fparent@baylibre.com>
Quoting Fabien Parent (2019-03-23 14:15:59)
> Add binding documentation of topckgen for MT8516 SoC.
>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> ---
Applied to clk-next
^ permalink raw reply
* Re: [PATCH 12/24] dt-bindings: mediatek: infracfg: add support for MT8516
From: Stephen Boyd @ 2019-04-25 21:34 UTC (permalink / raw)
To: mark.rutland, matthias.bgg, robh+dt
Cc: sean.wang, ryder.lee, hsin-hsiung.wang, wenzhen.yu, chaotian.jing,
yong.mao, jjian.zhou, devicetree, linux-kernel, linux-i2c,
linux-arm-kernel, linux-mediatek, linux-mmc, linux-gpio,
linux-serial, linux-spi, linux-watchdog, linux-clk,
stephane.leprovost, Fabien Parent
In-Reply-To: <20190323211612.860-13-fparent@baylibre.com>
Quoting Fabien Parent (2019-03-23 14:16:00)
> Add binding documentation of infracfg for MT8516 SoC.
>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> ---
Applied to clk-next
^ permalink raw reply
* Re: [PATCH 13/24] dt-bindings: mediatek: apmixedsys: add support for MT8516
From: Stephen Boyd @ 2019-04-25 21:35 UTC (permalink / raw)
To: mark.rutland, matthias.bgg, robh+dt
Cc: sean.wang, ryder.lee, hsin-hsiung.wang, wenzhen.yu, chaotian.jing,
yong.mao, jjian.zhou, devicetree, linux-kernel, linux-i2c,
linux-arm-kernel, linux-mediatek, linux-mmc, linux-gpio,
linux-serial, linux-spi, linux-watchdog, linux-clk,
stephane.leprovost, Fabien Parent
In-Reply-To: <20190323211612.860-14-fparent@baylibre.com>
Quoting Fabien Parent (2019-03-23 14:16:01)
> Add binding documentation of apmixedsys for MT8516 SoC.
>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> ---
Applied to clk-next
^ permalink raw reply
* Re: [PATCH 14/24] clk: mediatek: add clock driver for MT8516
From: Stephen Boyd @ 2019-04-25 21:39 UTC (permalink / raw)
To: mark.rutland, matthias.bgg, robh+dt
Cc: sean.wang, ryder.lee, hsin-hsiung.wang, wenzhen.yu, chaotian.jing,
yong.mao, jjian.zhou, devicetree, linux-kernel, linux-i2c,
linux-arm-kernel, linux-mediatek, linux-mmc, linux-gpio,
linux-serial, linux-spi, linux-watchdog, linux-clk,
stephane.leprovost, Fabien Parent
In-Reply-To: <20190323211612.860-15-fparent@baylibre.com>
Quoting Fabien Parent (2019-03-23 14:16:02)
> Add the clock driver for the MT8516 SoC.
>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> ---
Applied to clk-next
^ permalink raw reply
* Re: [PATCH 1/2] serial: 8250-mtk: add follow control
From: Long Cheng @ 2019-04-26 5:22 UTC (permalink / raw)
To: Matthias Brugger
Cc: Greg Kroah-Hartman, Jiri Slaby, Gustavo A. R. Silva, Peter Shih,
linux-serial, linux-arm-kernel, linux-mediatek, linux-kernel,
srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu, Changqi Hu
In-Reply-To: <a43c54c4-e0bc-f9c7-9228-58938058c3b7@gmail.com>
On Thu, 2019-04-25 at 12:40 +0200, Matthias Brugger wrote:
>
> On 25/04/2019 10:41, Long Cheng wrote:
> > Add SW and HW follow control function.
>
> Can you please explain a bit more what you are doing in this patch.
> You change the setting of the registers for different baud rates. Please
> elaborate what is happening there.
>
Clock source is different. Sometimes, baudrate is greater than or equal
to 115200, we use highspeed of 3 algorithm and fractional divider to
ensure more accurate baudrate.
Next release version, I will update this to commit message
> >
> > Signed-off-by: Long Cheng <long.cheng@mediatek.com>
> > ---
> > drivers/tty/serial/8250/8250_mtk.c | 60 ++++++++++++++++++++++--------------
> > 1 file changed, 37 insertions(+), 23 deletions(-)
> >
> > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> > index c1fdbc0..959fd85 100644
> > --- a/drivers/tty/serial/8250/8250_mtk.c
> > +++ b/drivers/tty/serial/8250/8250_mtk.c
> > @@ -21,12 +21,14 @@
> >
> > #include "8250.h"
> >
> > -#define UART_MTK_HIGHS 0x09 /* Highspeed register */
> > -#define UART_MTK_SAMPLE_COUNT 0x0a /* Sample count register */
> > -#define UART_MTK_SAMPLE_POINT 0x0b /* Sample point register */
> > +#define MTK_UART_HIGHS 0x09 /* Highspeed register */
> > +#define MTK_UART_SAMPLE_COUNT 0x0a /* Sample count register */
> > +#define MTK_UART_SAMPLE_POINT 0x0b /* Sample point register */
>
> Rename looks good to me. But I'd prefer to have it in a separate patch.
>
OK.
> > #define MTK_UART_RATE_FIX 0x0d /* UART Rate Fix Register */
> > -
> > #define MTK_UART_DMA_EN 0x13 /* DMA Enable register */
> > +#define MTK_UART_RXTRI_AD 0x14 /* RX Trigger address */
> > +#define MTK_UART_FRACDIV_L 0x15 /* Fractional divider LSB address */
> > +#define MTK_UART_FRACDIV_M 0x16 /* Fractional divider MSB address */
> > #define MTK_UART_DMA_EN_TX 0x2
> > #define MTK_UART_DMA_EN_RX 0x5
> >
> > @@ -46,6 +48,7 @@ enum dma_rx_status {
> > struct mtk8250_data {
> > int line;
> > unsigned int rx_pos;
> > + unsigned int clk_count;
>
> What is that for, not used in this patch.
>
It's for other patch. Sorry, I will remove it.
> > struct clk *uart_clk;
> > struct clk *bus_clk;
> > struct uart_8250_dma *dma;
> > @@ -196,9 +199,15 @@ static void mtk8250_shutdown(struct uart_port *port)
> > mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
> > struct ktermios *old)
> > {
> > + unsigned short fraction_L_mapping[] = {
> > + 0, 1, 0x5, 0x15, 0x55, 0x57, 0x57, 0x77, 0x7F, 0xFF, 0xFF
> > + };
> > + unsigned short fraction_M_mapping[] = {
> > + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 3
> > + };
> > struct uart_8250_port *up = up_to_u8250p(port);
> > + unsigned int baud, quot, fraction;
> > unsigned long flags;
> > - unsigned int baud, quot;
> >
> > #ifdef CONFIG_SERIAL_8250_DMA
> > if (up->dma) {
> > @@ -214,7 +223,7 @@ static void mtk8250_shutdown(struct uart_port *port)
> > serial8250_do_set_termios(port, termios, old);
> >
> > /*
> > - * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS)
> > + * Mediatek UARTs use an extra highspeed register (MTK_UART_HIGHS)
> > *
> > * We need to recalcualte the quot register, as the claculation depends
> > * on the vaule in the highspeed register.
> > @@ -230,18 +239,11 @@ static void mtk8250_shutdown(struct uart_port *port)
> > port->uartclk / 16 / UART_DIV_MAX,
> > port->uartclk);
> >
> > - if (baud <= 115200) {
> > - serial_port_out(port, UART_MTK_HIGHS, 0x0);
> > + if (baud < 115200) {
> > + serial_port_out(port, MTK_UART_HIGHS, 0x0);
> > quot = uart_get_divisor(port, baud);
> > - } else if (baud <= 576000) {
> > - serial_port_out(port, UART_MTK_HIGHS, 0x2);
> > -
> > - /* Set to next lower baudrate supported */
> > - if ((baud == 500000) || (baud == 576000))
> > - baud = 460800;
> > - quot = DIV_ROUND_UP(port->uartclk, 4 * baud);
>
> So we allow now also these baud rates? Then you have to update the comment as well.
>
Yes.
When clock source is different, data sometimes is error by the previous
algorithm. It's not good. So we update new method to fix the issue.
> Regards,
> Matthias
>
> > } else {
> > - serial_port_out(port, UART_MTK_HIGHS, 0x3);
> > + serial_port_out(port, MTK_UART_HIGHS, 0x3);
> > quot = DIV_ROUND_UP(port->uartclk, 256 * baud);
> > }
> >
> > @@ -258,17 +260,29 @@ static void mtk8250_shutdown(struct uart_port *port)
> > /* reset DLAB */
> > serial_port_out(port, UART_LCR, up->lcr);
> >
> > - if (baud > 460800) {
> > + if (baud >= 115200) {
> > unsigned int tmp;
> >
> > - tmp = DIV_ROUND_CLOSEST(port->uartclk, quot * baud);
> > - serial_port_out(port, UART_MTK_SAMPLE_COUNT, tmp - 1);
> > - serial_port_out(port, UART_MTK_SAMPLE_POINT,
> > - (tmp - 2) >> 1);
> > + tmp = (port->uartclk / (baud * quot)) - 1;
> > + serial_port_out(port, MTK_UART_SAMPLE_COUNT, tmp);
> > + serial_port_out(port, MTK_UART_SAMPLE_POINT,
> > + (tmp >> 1) - 1);
> > +
> > + /*count fraction to set fractoin register */
> > + fraction = ((port->uartclk * 100) / baud / quot) % 100;
> > + fraction = DIV_ROUND_CLOSEST(fraction, 10);
> > + serial_port_out(port, MTK_UART_FRACDIV_L,
> > + fraction_L_mapping[fraction]);
> > + serial_port_out(port, MTK_UART_FRACDIV_M,
> > + fraction_M_mapping[fraction]);
> > } else {
> > - serial_port_out(port, UART_MTK_SAMPLE_COUNT, 0x00);
> > - serial_port_out(port, UART_MTK_SAMPLE_POINT, 0xff);
> > + serial_port_out(port, MTK_UART_SAMPLE_COUNT, 0x00);
> > + serial_port_out(port, MTK_UART_SAMPLE_POINT, 0xff);
> > + serial_port_out(port, MTK_UART_FRACDIV_L, 0x00);
> > + serial_port_out(port, MTK_UART_FRACDIV_M, 0x00);
> > }
> > + if (uart_console(port))
> > + up->port.cons->cflag = termios->c_cflag;
> >
> > spin_unlock_irqrestore(&port->lock, flags);
> > /* Don't rewrite B0 */
> >
^ permalink raw reply
* [PATCH 1/2] serial: 8250: Allow port registration without UPF_BOOT_AUTOCONF
From: Esben Haabendal @ 2019-04-26 8:36 UTC (permalink / raw)
To: linux-serial
Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Darwin Dingel,
He Zhe, Sebastian Andrzej Siewior, Jisheng Zhang, linux-kernel
With serial8250_register_8250_port() forcing UPF_BOOT_AUTOCONF bit on, it
is not possible to register a port without having
serial8250_request_std_resource() called.
For adding a 8250 port to an MFD device, this is problematic, as the
request_mem_region() call will fail, as the MFD device (and rightly so)
has requested the region. For this case, the 8250 port should accept
having passed mapbase and membase, and just use that.
Signed-off-by: Esben Haabendal <esben@geanix.com>
---
drivers/tty/serial/8250/8250_core.c | 36 +++++++++++++++++++++---------------
include/linux/serial_8250.h | 2 ++
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index e441221..ddbb0a0 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -957,20 +957,8 @@ static void serial_8250_overrun_backoff_work(struct work_struct *work)
spin_unlock_irqrestore(&port->lock, flags);
}
-/**
- * serial8250_register_8250_port - register a serial port
- * @up: serial port template
- *
- * Configure the serial port specified by the request. If the
- * port exists and is in use, it is hung up and unregistered
- * first.
- *
- * The port is then probed and if necessary the IRQ is autodetected
- * If this fails an error is returned.
- *
- * On success the port is ready to use and the line number is returned.
- */
-int serial8250_register_8250_port(struct uart_8250_port *up)
+int __serial8250_register_8250_port(struct uart_8250_port *up,
+ unsigned int extra_flags)
{
struct uart_8250_port *uart;
int ret = -ENOSPC;
@@ -993,7 +981,7 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
uart->port.fifosize = up->port.fifosize;
uart->port.regshift = up->port.regshift;
uart->port.iotype = up->port.iotype;
- uart->port.flags = up->port.flags | UPF_BOOT_AUTOCONF;
+ uart->port.flags = up->port.flags | extra_flags;
uart->bugs = up->bugs;
uart->port.mapbase = up->port.mapbase;
uart->port.mapsize = up->port.mapsize;
@@ -1086,6 +1074,24 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
return ret;
}
+
+/**
+ * serial8250_register_8250_port - register a serial port
+ * @up: serial port template
+ *
+ * Configure the serial port specified by the request. If the
+ * port exists and is in use, it is hung up and unregistered
+ * first.
+ *
+ * The port is then probed and if necessary the IRQ is autodetected
+ * If this fails an error is returned.
+ *
+ * On success the port is ready to use and the line number is returned.
+ */
+int serial8250_register_8250_port(struct uart_8250_port *up)
+{
+ return __serial8250_register_8250_port(up, UPF_BOOT_AUTOCONF);
+}
EXPORT_SYMBOL(serial8250_register_8250_port);
/**
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 5a655ba..9d1fe2e 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -145,6 +145,8 @@ static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up)
return container_of(up, struct uart_8250_port, port);
}
+extern int __serial8250_register_8250_port(struct uart_8250_port *,
+ unsigned int);
int serial8250_register_8250_port(struct uart_8250_port *);
void serial8250_unregister_port(int line);
void serial8250_suspend_port(int line);
--
2.4.11
^ permalink raw reply related
* [PATCH 0/2] serial: 8250: Add support for 8250/16550 as MFD function
From: Esben Haabendal @ 2019-04-26 8:40 UTC (permalink / raw)
To: linux-serial, Greg Kroah-Hartman, Jiri Slaby
Cc: Andy Shevchenko, Darwin Dingel, Florian Fainelli, He Zhe,
Jisheng Zhang, Lokesh Vutla, Sebastian Andrzej Siewior,
Tony Lindgren, linux-kernel
This series adds a driver for adding 8250/16550 UART ports as functions to
MFD devices.
Esben Haabendal (2):
serial: 8250: Allow port registration without UPF_BOOT_AUTOCONF
serial: 8250: Add support for 8250/16550 as MFD function
drivers/tty/serial/8250/8250_core.c | 36 ++++++-----
drivers/tty/serial/8250/8250_mfd.c | 119 ++++++++++++++++++++++++++++++++++++
drivers/tty/serial/8250/Kconfig | 12 ++++
drivers/tty/serial/8250/Makefile | 1 +
include/linux/serial_8250.h | 2 +
5 files changed, 155 insertions(+), 15 deletions(-)
create mode 100644 drivers/tty/serial/8250/8250_mfd.c
--
2.4.11
^ permalink raw reply
* [PATCH 1/2] serial: 8250: Allow port registration without UPF_BOOT_AUTOCONF
From: Esben Haabendal @ 2019-04-26 8:40 UTC (permalink / raw)
To: linux-serial, Greg Kroah-Hartman, Jiri Slaby
Cc: Darwin Dingel, Andy Shevchenko, He Zhe, Jisheng Zhang,
Sebastian Andrzej Siewior, linux-kernel
In-Reply-To: <20190426084038.6377-1-esben@geanix.com>
With serial8250_register_8250_port() forcing UPF_BOOT_AUTOCONF bit on, it
is not possible to register a port without having
serial8250_request_std_resource() called.
For adding a 8250 port to an MFD device, this is problematic, as the
request_mem_region() call will fail, as the MFD device (and rightly so)
has requested the region. For this case, the 8250 port should accept
having passed mapbase and membase, and just use that.
Signed-off-by: Esben Haabendal <esben@geanix.com>
---
drivers/tty/serial/8250/8250_core.c | 36 +++++++++++++++++++++---------------
include/linux/serial_8250.h | 2 ++
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index e441221..ddbb0a0 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -957,20 +957,8 @@ static void serial_8250_overrun_backoff_work(struct work_struct *work)
spin_unlock_irqrestore(&port->lock, flags);
}
-/**
- * serial8250_register_8250_port - register a serial port
- * @up: serial port template
- *
- * Configure the serial port specified by the request. If the
- * port exists and is in use, it is hung up and unregistered
- * first.
- *
- * The port is then probed and if necessary the IRQ is autodetected
- * If this fails an error is returned.
- *
- * On success the port is ready to use and the line number is returned.
- */
-int serial8250_register_8250_port(struct uart_8250_port *up)
+int __serial8250_register_8250_port(struct uart_8250_port *up,
+ unsigned int extra_flags)
{
struct uart_8250_port *uart;
int ret = -ENOSPC;
@@ -993,7 +981,7 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
uart->port.fifosize = up->port.fifosize;
uart->port.regshift = up->port.regshift;
uart->port.iotype = up->port.iotype;
- uart->port.flags = up->port.flags | UPF_BOOT_AUTOCONF;
+ uart->port.flags = up->port.flags | extra_flags;
uart->bugs = up->bugs;
uart->port.mapbase = up->port.mapbase;
uart->port.mapsize = up->port.mapsize;
@@ -1086,6 +1074,24 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
return ret;
}
+
+/**
+ * serial8250_register_8250_port - register a serial port
+ * @up: serial port template
+ *
+ * Configure the serial port specified by the request. If the
+ * port exists and is in use, it is hung up and unregistered
+ * first.
+ *
+ * The port is then probed and if necessary the IRQ is autodetected
+ * If this fails an error is returned.
+ *
+ * On success the port is ready to use and the line number is returned.
+ */
+int serial8250_register_8250_port(struct uart_8250_port *up)
+{
+ return __serial8250_register_8250_port(up, UPF_BOOT_AUTOCONF);
+}
EXPORT_SYMBOL(serial8250_register_8250_port);
/**
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 5a655ba..9d1fe2e 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -145,6 +145,8 @@ static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up)
return container_of(up, struct uart_8250_port, port);
}
+extern int __serial8250_register_8250_port(struct uart_8250_port *,
+ unsigned int);
int serial8250_register_8250_port(struct uart_8250_port *);
void serial8250_unregister_port(int line);
void serial8250_suspend_port(int line);
--
2.4.11
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox