All of lore.kernel.org
 help / color / mirror / Atom feed
From: Neil Armstrong <narmstrong@baylibre.com>
To: Heiner Kallweit <hkallweit1@gmail.com>, Yu Tu <yu.tu@amlogic.com>
Cc: "open list:ARM/Amlogic Meson..." <linux-amlogic@lists.infradead.org>
Subject: Re: [PATCH RFC] tty: serial: meson: add new compatible for gxl uart
Date: Tue, 26 Apr 2022 09:21:55 +0200	[thread overview]
Message-ID: <2e0d53d9-5770-7d47-4dd5-9302ee8d546b@baylibre.com> (raw)
In-Reply-To: <fd06c40a-4f63-3b93-8471-477506f4ef38@gmail.com>

Hi,

On 25/04/2022 22:39, Heiner Kallweit wrote:
> 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.

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.

> 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

> 
> 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);


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2022-04-26  7:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25 20:39 [PATCH RFC] tty: serial: meson: add new compatible for gxl uart Heiner Kallweit
2022-04-26  7:21 ` Neil Armstrong [this message]
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=2e0d53d9-5770-7d47-4dd5-9302ee8d546b@baylibre.com \
    --to=narmstrong@baylibre.com \
    --cc=hkallweit1@gmail.com \
    --cc=linux-amlogic@lists.infradead.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.