tty: serial: meson: add new compatible for gxl uart
Subsystems (2)
RFC PATCH 1/1 tty: serial: meson: add new compatible for gxl uart
My SC2 test system (ah212-based HK1 RBOX X4) uses an uboot console speed of 921600 bps. Being able to use the same speed in Linux requires using a 12MHz clock source. Ideally we'd set the new compatible to the first chip version supporting the AML_UART_BAUD_XTAL_DIV2 bit. Not having access to chip documentation I'd appreciate a hint on when this bit was introduced.
If fine with you in general the final series would include a separate patch for the new compatible.
Note: This patch doesn't consider "tty: serial: meson:
Use DIV_ROUND_CLOSEST to calculate baud rates" yet and therefore won't apply cleanly on linux-next.
I locally used the same DIV_ROUND_CLOSEST() changes before.
----------------------------------------------------------------
Newer SoC versions support using XTAL / 2 (12MHz) as clock source for the UART. This clock source allows to support 921600 bps as used by vendor uboot on certain systems like ah212 ref board.
12MHz / 13 = 923076 bps
With the currently used 8MHz clock source only 888888bps or 1000000 bps are possible.
--- drivers/tty/serial/meson_uart.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/tty/serial/meson_uart.c +10 -3
@@ -68,6 +68,7 @@#define AML_UART_BAUD_MASK 0x7fffff#define AML_UART_BAUD_USE BIT(23)#define AML_UART_BAUD_XTAL BIT(24) +#define AML_UART_BAUD_XTAL_DIV2 BIT(27)#define AML_UART_PORT_NUM 12#define AML_UART_PORT_OFFSET 6
@@ -299,10 +300,15 @@ static void meson_uart_change_speed(struct uart_port *port, unsigned long baud)cpu_relax ();if (port->uartclk ==24000000 ) { - val = ((port->uartclk /3 ) / baud) -1 ; - val |=AML_UART_BAUD_XTAL ; +if (of_device_is_compatible (port->dev->of_node,"amlogic,meson-gxl-uart" )) { + val =DIV_ROUND_CLOSEST (port->uartclk,2 * baud) -1 ; + val |=AML_UART_BAUD_XTAL |AML_UART_BAUD_XTAL_DIV2 ; + }else { + val =DIV_ROUND_CLOSEST (port->uartclk,3 * baud) -1 ; + val |=AML_UART_BAUD_XTAL ; + } }else { - val = ((port->uartclk *10 / (baud *4 ) +5 ) /10 ) -1 ; + val =DIV_ROUND_CLOSEST (port->uartclk,4 * baud) -1 ; } val |=AML_UART_BAUD_USE ;writel (val, port->membase +AML_UART_REG5 );
@@ -782,6 +788,7 @@ static const struct of_device_id meson_uart_dt_match[] = { { .compatible = "amlogic,meson8-uart" }, { .compatible = "amlogic,meson8b-uart" }, { .compatible = "amlogic,meson-gx-uart" }, + { .compatible = "amlogic,meson-gxl-uart" }, { /* sentinel */ }, };MODULE_DEVICE_TABLE (of, meson_uart_dt_match);
Signature · 7 lines
2.35.3 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Hi,
Quoted 5 lines · Heiner Kallweit
My SC2 test system (ah212-based HK1 RBOX X4) uses an uboot console speed of 921600 bps. Being able to use the same speed in Linux requires using a 12MHz clock source. Ideally we'd set the new compatible to the first chip version supporting the
AML_UART_BAUD_XTAL_DIV2bit.
Actually G12A is the first chip having AML_UART_BAUD_XTAL_DIV2, but SC2 is the first one requiring it to achieve 921600 bps correctly.
Quoted 4 lines
Not having access to chip documentation
I'd appreciate a hint on when this bit was introduced. If fine with you in general the final series would include a separate patch for the new compatible.
This has been already handled in:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?h=tty-next&id=368ab68b18de104719f386a5cfe3595673cc96de
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?h=tty-next&id=00a7fa836dbc454faf5b7027ad67519af7c6c15b
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?h=tty-next&id=9b92cc5ee2d10e6c4d327d1e4ceb77aa8b1081ee
Quoted 51 lines
Note: This patch doesn't consider "tty: serial: meson:
UseDIV_ROUND_CLOSESTto calculate baud rates" yet and therefore won't apply cleanly on linux-next.
I locally used the sameDIV_ROUND_CLOSEST()changes before.
----------------------------------------------------------------
Newer SoC versions support using XTAL / 2 (12MHz) as clock source for the UART. This clock source allows to support 921600 bps as used by vendor uboot on certain systems like ah212 ref board.12MHz / 13 = 923076 bps
With the currently used 8MHz clock source only 888888bps or 1000000 bps are possible.Signed-off-by Heiner Kallweit <[email protected]>--- drivers/tty/serial/meson_uart.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)drivers/tty/serial/meson_uart.c +9
-3@@ -68,6 +68,7 @@#define AML_UART_BAUD_MASK 0x7fffff#define AML_UART_BAUD_USE BIT(23)#define AML_UART_BAUD_XTAL BIT(24) +#define AML_UART_BAUD_XTAL_DIV2 BIT(27)#define AML_UART_PORT_NUM 12#define AML_UART_PORT_OFFSET 6@@ -299,10 +300,15 @@ static void meson_uart_change_speed(struct uart_port *port, unsigned long baud)cpu_relax ();if (port->uartclk ==24000000 ) { - val = ((port->uartclk /3 ) / baud) -1 ; - val |=AML_UART_BAUD_XTAL ; +if (of_device_is_compatible (port->dev->of_node,"amlogic,meson-gxl-uart" )) { + val =DIV_ROUND_CLOSEST (port->uartclk,2 * baud) -1 ; + val |=AML_UART_BAUD_XTAL |AML_UART_BAUD_XTAL_DIV2 ; + }else { + val =DIV_ROUND_CLOSEST (port->uartclk,3 * baud) -1 ; + val |=AML_UART_BAUD_XTAL ; + } }else { - val = ((port->uartclk *10 / (baud *4 ) +5 ) /10 ) -1 ; + val =DIV_ROUND_CLOSEST (port->uartclk,4 * baud) -1 ; } val |=AML_UART_BAUD_USE ;writel (val, port->membase +AML_UART_REG5 );
drivers/tty/serial/meson_uart.c static const struct of_device_id meson_uart_dt_match[] = { · line 794
Quoted 7 lines
drivers/tty/serial/meson_uart.c +1
-0@@ -782,6 +788,7 @@ static const struct of_device_id meson_uart_dt_match[] = { { .compatible = "amlogic,meson8-uart" }, { .compatible = "amlogic,meson8b-uart" }, { .compatible = "amlogic,meson-gx-uart" }, + { .compatible = "amlogic,meson-gxl-uart" }, { /* sentinel */ }, };MODULE_DEVICE_TABLE (of, meson_uart_dt_match);
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
Quoted 17 lines · Neil Armstrong
Hi,
Quoted 5 lines · Heiner Kallweit
My SC2 test system (ah212-based HK1 RBOX X4) uses an uboot console speed of 921600 bps. Being able to use the same speed in Linux requires using a 12MHz clock source. Ideally we'd set the new compatible to the first chip version supporting the
AML_UART_BAUD_XTAL_DIV2bit.Actually G12A is the first chip having
AML_UART_BAUD_XTAL_DIV2, but SC2 is the first one requiring it to achieve 921600 bps correctly.Quoted 4 lines
Not having access to chip documentation
I'd appreciate a hint on when this bit was introduced. If fine with you in general the final series would include a separate patch for the new compatible.
Quoted 5 lines
This has been already handled in:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?h=tty-next&id=368ab68b18de104719f386a5cfe3595673cc96de
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?h=tty-next&id=00a7fa836dbc454faf5b7027ad67519af7c6c15b
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?h=tty-next&id=9b92cc5ee2d10e6c4d327d1e4ceb77aa8b1081ee
Good to know, thanks for the hint!
Quoted 48 lines
Quoted 48 lines
Note: This patch doesn't consider "tty: serial: meson:
UseDIV_ROUND_CLOSESTto calculate baud rates" yet and therefore won't apply cleanly on linux-next.
I locally used the sameDIV_ROUND_CLOSEST()changes before.
----------------------------------------------------------------
Newer SoC versions support using XTAL / 2 (12MHz) as clock source for the UART. This clock source allows to support 921600 bps as used by vendor uboot on certain systems like ah212 ref board.12MHz / 13 = 923076 bps
With the currently used 8MHz clock source only 888888bps or 1000000 bps are possible.Signed-off-by Heiner Kallweit <[email protected]>---
drivers/tty/serial/meson_uart.c| 13 ++++++++++---1 file changed, 10 insertions(+), 3 deletions(-)drivers/tty/serial/meson_uart.c +9
-3@@ -68,6 +68,7 @@ #define AML_UART_BAUD_MASK 0x7fffff #define AML_UART_BAUD_USE BIT(23) #define AML_UART_BAUD_XTAL BIT(24) +#define AML_UART_BAUD_XTAL_DIV2 BIT(27) #define AML_UART_PORT_NUM 12 #define AML_UART_PORT_OFFSET 6@@ -299,10 +300,15 @@ static void meson_uart_change_speed(struct uart_port *port, unsigned long baud) cpu_relax(); if (port->uartclk == 24000000) { - val = ((port->uartclk / 3) / baud) - 1; - val |= AML_UART_BAUD_XTAL; + if (of_device_is_compatible(port->dev->of_node, "amlogic,meson-gxl-uart")) { + val = DIV_ROUND_CLOSEST(port->uartclk, 2 * baud) - 1; + val |= AML_UART_BAUD_XTAL | AML_UART_BAUD_XTAL_DIV2; + } else { + val = DIV_ROUND_CLOSEST(port->uartclk, 3 * baud) - 1; + val |= AML_UART_BAUD_XTAL; + } } else { - val = ((port->uartclk * 10 / (baud * 4) + 5) / 10) - 1; + val = DIV_ROUND_CLOSEST(port->uartclk, 4 * baud) - 1; } val |= AML_UART_BAUD_USE; writel(val, port->membase + AML_UART_REG5);
Quoted 9 lines
drivers/tty/serial/meson_uart.c static const struct of_device_id meson_uart_dt_match[] = { · line 794
Quoted 8 lines
drivers/tty/serial/meson_uart.c +1
-0@@ -782,6 +788,7 @@ static const struct of_device_id meson_uart_dt_match[] = { { .compatible = "amlogic,meson8-uart" }, { .compatible = "amlogic,meson8b-uart" }, { .compatible = "amlogic,meson-gx-uart" }, + { .compatible = "amlogic,meson-gxl-uart" }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, meson_uart_dt_match);
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic