From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Judith Mendez <jm@ti.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>, Nishanth Menon <nm@ti.com>,
Santosh Shilimkar <ssantosh@kernel.org>,
Vignesh Raghavendra <vigneshr@ti.com>,
Tero Kristo <kristo@kernel.org>, Bin Liu <b-liu@ti.com>,
Andrew Davis <afd@ti.com>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 3/7] serial: 8250: Add PRUSS UART driver
Date: Wed, 14 May 2025 15:21:32 +0300 [thread overview]
Message-ID: <aCSKzFHGl5ua3rrP@smile.fi.intel.com> (raw)
In-Reply-To: <20250513215934.933807-4-jm@ti.com>
On Tue, May 13, 2025 at 04:59:30PM -0500, Judith Mendez wrote:
> From: Bin Liu <b-liu@ti.com>
>
> This adds a new serial 8250 driver that supports the UART in PRUSS or
> PRU_ICSS*.
>
> The UART sub-module is based on the industry standard TL16C550 UART
> controller, which has 16-bytes FIFO and supports 16x and 13x over
> samplings.
...
+ bits.h
> +#include <linux/clk.h>
+ math.h
> +#include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/platform_device.h>
> +#include <linux/serial_reg.h>
> +#include <linux/serial_core.h>
Can you keep them sorted?
...
> +static int pruss8250_startup(struct uart_port *port)
> +{
> + int ret;
> +
> + port->serial_out(port, PRUSS_UART_PEREMU_MGMT, 0);
> +
> + ret = serial8250_do_startup(port);
Please, use standard pattern, i.e.
if (ret)
return ret;
...
return 0;
I believe I have told this previously. Can you double check that you read and
addressed all of the comments?
> + if (!ret)
> + port->serial_out(port, PRUSS_UART_PEREMU_MGMT, PRUSS_UART_TX_EN |
> + PRUSS_UART_RX_EN |
> + PRUSS_UART_FREE_RUN);
> +
> + return ret;
> +}
...
> +static unsigned int pruss8250_get_divisor(struct uart_port *port,
> + unsigned int baud,
> + unsigned int *frac)
> +{
> + unsigned int uartclk = port->uartclk;
> + unsigned int div_13, div_16;
> + unsigned int abs_d13, abs_d16;
> + u16 quot;
> +
> + div_13 = DIV_ROUND_CLOSEST(uartclk, 13 * baud);
> + div_16 = DIV_ROUND_CLOSEST(uartclk, 16 * baud);
> + div_13 = div_13 ? : 1;
> + div_16 = div_16 ? : 1;
> +
> + abs_d13 = abs(baud - uartclk / 13 / div_13);
> + abs_d16 = abs(baud - uartclk / 16 / div_16);
> +
> + if (abs_d13 >= abs_d16) {
Isn't this something like abs_diff() ?
> + *frac = PRUSS_UART_MDR_16X_MODE;
> + quot = div_16;
> + } else {
> + *frac = PRUSS_UART_MDR_13X_MODE;
> + quot = div_13;
> + }
> +
> + return quot;
> +}
> +static int pruss8250_probe(struct platform_device *pdev)
> +{
> + struct uart_8250_port port8250;
> + struct uart_port *port = &port8250.port;
> + struct device *dev = &pdev->dev;
> + struct pruss8250_data *data;
> + struct resource *res;
> + int ret;
> +
> + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
Needs device/devres.h.
> + if (!data)
> + return -ENOMEM;
Needs err.h (actually errno.h, but that's not enough for the following IS_ERR()
et al.)
> + memset(&port8250, 0, sizeof(port8250));
Instead of having dependency on string.h (which is missed) just assign it to {}
in the definition.
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res) {
> + dev_err(&pdev->dev, "Failed to get resource");
> + return -EINVAL;
return dev_err_probe();
> + }
> + if (!port->uartclk) {
> + data->clk = devm_clk_get(dev, NULL);
> + if (IS_ERR(data->clk)) {
> + dev_err(dev, "Failed to get clock!\n");
> + return -ENODEV;
> + } else {
> + port->uartclk = clk_get_rate(data->clk);
> + devm_clk_put(dev, data->clk);
I think you completely ignored my review I have done in previous version...
> + }
> + }
Should be done after uart_read_properties().
> + port->dev = dev;
> + port->mapbase = res->start;
> + port->mapsize = resource_size(res);
> + port->type = PORT_16550A;
> + port->flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_FIXED_TYPE |
> + UPF_IOREMAP;
> + port->startup = pruss8250_startup;
> + port->rs485_config = serial8250_em485_config;
> + port->get_divisor = pruss8250_get_divisor;
> + port->set_divisor = pruss8250_set_divisor;
> +
> + ret = uart_read_port_properties(port);
> + if (ret)
> + return ret;
> +
> + port->iotype = UPIO_MEM32;
> + port->regshift = 2;
> +
> + spin_lock_init(&port8250.port.lock);
> + port8250.capabilities = UART_CAP_FIFO | UART_CAP_AFE;
> +
> + ret = serial8250_register_8250_port(&port8250);
> + if (ret < 0)
> + return dev_err_probe(dev, ret, "Unable to register 8250 port.\n");
> +
> + data->line = ret;
> + platform_set_drvdata(pdev, data);
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-05-14 12:21 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-13 21:59 [PATCH 0/7] Introduce PRU UART driver Judith Mendez
2025-05-13 21:59 ` [PATCH 1/7] dt-bindings: serial: add binding documentation for TI PRUSS UART Judith Mendez
2025-05-14 12:33 ` Krzysztof Kozlowski
2025-05-13 21:59 ` [PATCH 2/7] dt-bindings: soc: ti: pruss: Add documentation for PRU UART support Judith Mendez
2025-05-14 12:35 ` Krzysztof Kozlowski
2025-05-16 22:33 ` Judith Mendez
2025-05-13 21:59 ` [PATCH 3/7] serial: 8250: Add PRUSS UART driver Judith Mendez
2025-05-14 7:36 ` Greg Kroah-Hartman
2025-05-16 22:36 ` Judith Mendez
2025-05-14 12:21 ` Andy Shevchenko [this message]
2025-05-13 21:59 ` [PATCH 4/7] DONOTMERGE: arm64: dts: ti: k3-am64-main: Add PRU UART nodes Judith Mendez
2025-05-13 21:59 ` [PATCH 5/7] DONOTMERGE: arm64: dts: ti: k3-am642-sk: Enable PRU UART Judith Mendez
2025-05-13 21:59 ` [PATCH 6/7] DONOTMERGE: arm64: dts: ti: k3-am62-main: Add PRU UART node Judith Mendez
2025-05-13 21:59 ` [PATCH 7/7] DONOTMERGE: arm64: dts: ti: k3-am62x-sk: Enable PRU UART Judith Mendez
2025-05-14 7:35 ` [PATCH 0/7] Introduce PRU UART driver Greg Kroah-Hartman
2025-05-14 12:30 ` Krzysztof Kozlowski
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=aCSKzFHGl5ua3rrP@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=afd@ti.com \
--cc=b-liu@ti.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=jm@ti.com \
--cc=kristo@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=nm@ti.com \
--cc=robh@kernel.org \
--cc=ssantosh@kernel.org \
--cc=vigneshr@ti.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