From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Benjamin Larsson" <benjamin.larsson@genexis.eu>,
"John Ogness" <john.ogness@linutronix.de>,
"Peng Zhang" <zhangpeng.00@bytedance.com>,
"Lukas Wunner" <lukas@wunner.de>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Rong Zhang" <rongrong@oss.cipunited.com>,
"Binbin Zhou" <zhoubinbin@loongson.cn>,
"Gerhard Engleder" <eg@keba.com>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Lubomir Rintel" <lkundrak@v3.sk>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org
Subject: Re: [PATCH v3 2/2] serial: 8250: Add Airoha SoC UART and HSUART support
Date: Sat, 8 Aug 2026 21:10:20 +0300 [thread overview]
Message-ID: <andxDI4Xc-h5cJbd@ashevche-desk.local> (raw)
In-Reply-To: <20260807222044.208056-3-ansuelsmth@gmail.com>
On Sat, Aug 08, 2026 at 12:20:40AM +0200, Christian Marangi wrote:
> Add support for Airoha AN7523 UART and AN7581 HSUART.
>
> These implement a standard 16550 UART with only some custom logic
> for baud rate handling.
Some cosmetic issues below.
With that being addressed,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
...
> +++ b/drivers/tty/serial/8250/8250_airoha.c
> + * Author: Benjamin Larsson <benjamin.larsson@genexis.eu>
> + * Christian Marangi <ansuelsmth@gmail.com>
Authors:
...
> +#include <linux/array_size.h>
> +#include <linux/bits.h>
> +#include <linux/bitfield.h>
+ errno.h
> +#include <linux/math64.h>
> +#include <linux/module.h>
> +#include <linux/property.h>
> +#include <linux/platform_device.h>
> +#include <linux/serial_8250.h>
> +#include <linux/serial_core.h>
> +#include <linux/serial_reg.h>
These two are kinda guaranteed by serial_8250.h. At least IIRC some other 8250
drivers rely on this and it sounds logical.
+ types.h // uXX
> +#include <linux/units.h>
...
> +#define UART_BRD_20M 0x1
Perhaps 0x0001 to show that this is 16-bit value?
...
> +static unsigned int airoha_get_divisor(struct uart_port *port,
> + unsigned int baud,
> + unsigned int *frac)
> +{
> + /* Hardware always uses BRDIV = 1. */
> + *frac = 0;
> +
> + return 1;
Shouldn't this be the same as UART_BRD_20M? I mean return a defined constant.
> +}
...
> +static void airoha_set_divisor(struct uart_port *port, unsigned int baud,
> + unsigned int quot, unsigned int quot_frac)
> +{
> + struct uart_8250_port *up = up_to_u8250p(port);
> + u32 xindiv_clk;
> + u64 xyd_x, nom;
> + int div_bit;
> +
> + /* Set baud rate calculation defaults (BRDIV ([BRDH,BRDL]) to 1) */
Inner parentheses are not needed.
> + serial8250_do_set_divisor(port, baud, UART_BRD_20M);
> +
> + /*
> + * Calculate XYD_x and XINCLKDR register by searching
> + * through a table of crystal_clock divisors.
> + */
> + nom = (u64)baud * XYD_Y;
> + for (div_bit = ARRAY_SIZE(airoha_clk_divs) - 1;
> + div_bit >= 0; div_bit--) {
It's okay to place these on a single line.
> + unsigned int div = airoha_clk_divs[div_bit];
> +
> + xindiv_clk = XINDIV_CLOCK / div;
> + xyd_x = div_u64(nom * 16, xindiv_clk);
> +
> + /* For the HSUART xyd_x needs to be scaled by a factor of 2 */
> + if (port->type == UART_PORT_AIROHA_HS)
> + xyd_x /= 2;
> +
> + if (xyd_x < XYD_Y)
> + break;
> + }
> +
> + /* Couldn't find a valid xyd_x */
> + if (div_bit < 0) {
> + dev_err(port->dev, "failed to find suitable clock divisor for baud %u\n",
> + baud);
> + return;
> + }
> +
> + serial_port_out(port, UART_AIROHA_XINCLKDR, BIT(div_bit));
> + serial_port_out(port, UART_AIROHA_XYD,
> + FIELD_PREP(UART_AIROHA_XYD_X, xyd_x) |
> + FIELD_PREP(UART_AIROHA_XYD_Y, XYD_Y));
> +
> + /* Restore normal register access. */
> + serial_port_out(port, UART_LCR, up->lcr);
> +}
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-08-08 18:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 22:20 [PATCH v3 0/2] serial: 8250: Add AN7581 UART support Christian Marangi
2026-08-07 22:20 ` [PATCH v3 1/2] dt-bindings: serial: 8250: Add Airoha compatibles Christian Marangi
2026-08-07 22:20 ` [PATCH v3 2/2] serial: 8250: Add Airoha SoC UART and HSUART support Christian Marangi
2026-08-08 18:10 ` Andy Shevchenko [this message]
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=andxDI4Xc-h5cJbd@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=ansuelsmth@gmail.com \
--cc=benjamin.larsson@genexis.eu \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=eg@keba.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jiaxun.yang@flygoat.com \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lkundrak@v3.sk \
--cc=lukas@wunner.de \
--cc=rdunlap@infradead.org \
--cc=robh@kernel.org \
--cc=rongrong@oss.cipunited.com \
--cc=zhangpeng.00@bytedance.com \
--cc=zhoubinbin@loongson.cn \
/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