From: Heiner Kallweit <hkallweit1@gmail.com>
To: Neil Armstrong <narmstrong@baylibre.com>, Yu Tu <yu.tu@amlogic.com>
Cc: "open list:ARM/Amlogic Meson..." <linux-amlogic@lists.infradead.org>
Subject: [PATCH RFC] tty: serial: meson: add new compatible for gxl uart
Date: Mon, 25 Apr 2022 22:39:37 +0200 [thread overview]
Message-ID: <fd06c40a-4f63-3b93-8471-477506f4ef38@gmail.com> (raw)
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.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/tty/serial/meson_uart.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index 2bf1c57e0..0a0a0636f 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -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);
--
2.35.3
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next reply other threads:[~2022-04-25 20:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-25 20:39 Heiner Kallweit [this message]
2022-04-26 7:21 ` Neil Armstrong
2022-04-26 8:49 ` Heiner Kallweit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fd06c40a-4f63-3b93-8471-477506f4ef38@gmail.com \
--to=hkallweit1@gmail.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=narmstrong@baylibre.com \
--cc=yu.tu@amlogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®