From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org,
linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
linux-tegra@vger.kernel.org
Cc: "Jiri Slaby" <jirislaby@kernel.org>,
"Joel Stanley" <joel@jms.id.au>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Ray Jui" <rjui@broadcom.com>,
"Scott Branden" <sbranden@broadcom.com>,
"Broadcom internal kernel review list"
<bcm-kernel-feedback-list@broadcom.com>,
"Al Cooper" <alcooperx@gmail.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Paul Cercueil" <paul@crapouillou.net>,
"Vladimir Zapolskiy" <vz@mleia.com>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Jonathan Hunter" <jonathanh@nvidia.com>,
"Kunihiko Hayashi" <hayashi.kunihiko@socionext.com>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Andi Shyti" <andi.shyti@linux.intel.com>
Subject: [PATCH v1 10/14] serial: 8250_of: Switch to use uart_read_port_properties()
Date: Wed, 21 Feb 2024 20:31:26 +0200 [thread overview]
Message-ID: <20240221183442.4124354-11-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20240221183442.4124354-1-andriy.shevchenko@linux.intel.com>
Since we have now a common helper to read port properties
use it instead of sparse home grown solution.
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/tty/serial/8250/8250_of.c | 105 +++++++-----------------------
1 file changed, 22 insertions(+), 83 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 9dcc17e33269..1a699ce2e812 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -69,37 +69,22 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
struct device *dev = &ofdev->dev;
struct device_node *np = dev->of_node;
struct uart_port *port = &up->port;
- u32 clk, spd, prop;
- int ret, irq;
+ u32 spd;
+ int ret;
memset(port, 0, sizeof *port);
pm_runtime_enable(&ofdev->dev);
pm_runtime_get_sync(&ofdev->dev);
- if (of_property_read_u32(np, "clock-frequency", &clk)) {
-
- /* Get clk rate through clk driver if present */
- info->clk = devm_clk_get_enabled(dev, NULL);
- if (IS_ERR(info->clk)) {
- ret = dev_err_probe(dev, PTR_ERR(info->clk), "failed to get clock\n");
- goto err_pmruntime;
- }
-
- clk = clk_get_rate(info->clk);
- }
- /* If current-speed was set, then try not to change it. */
- if (of_property_read_u32(np, "current-speed", &spd) == 0)
- port->custom_divisor = clk / (16 * spd);
-
ret = of_address_to_resource(np, 0, &resource);
if (ret) {
dev_err_probe(dev, ret, "invalid address\n");
goto err_pmruntime;
}
- port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT |
- UPF_FIXED_TYPE;
+ port->dev = &ofdev->dev;
+ port->flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_FIXED_TYPE;
spin_lock_init(&port->lock);
if (resource_type(&resource) == IORESOURCE_IO) {
@@ -108,70 +93,31 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
} else {
port->mapbase = resource.start;
port->mapsize = resource_size(&resource);
-
- /* Check for shifted address mapping */
- if (of_property_read_u32(np, "reg-offset", &prop) == 0) {
- if (prop >= port->mapsize) {
- ret = dev_err_probe(dev, -EINVAL, "reg-offset %u exceeds region size %pa\n",
- prop, &port->mapsize);
- goto err_pmruntime;
- }
-
- port->mapbase += prop;
- port->mapsize -= prop;
- }
-
- port->iotype = UPIO_MEM;
- if (of_property_read_u32(np, "reg-io-width", &prop) == 0) {
- switch (prop) {
- case 1:
- port->iotype = UPIO_MEM;
- break;
- case 2:
- port->iotype = UPIO_MEM16;
- break;
- case 4:
- port->iotype = of_device_is_big_endian(np) ?
- UPIO_MEM32BE : UPIO_MEM32;
- break;
- default:
- ret = dev_err_probe(dev, -EINVAL, "unsupported reg-io-width (%u)\n",
- prop);
- goto err_pmruntime;
- }
- }
port->flags |= UPF_IOREMAP;
}
+ ret = uart_read_port_properties(port, false);
+ if (ret)
+ goto err_pmruntime;
+
+ /* Get clk rate through clk driver if present */
+ if (!port->uartclk) {
+ info->clk = devm_clk_get_enabled(dev, NULL);
+ if (IS_ERR(info->clk)) {
+ ret = dev_err_probe(dev, PTR_ERR(info->clk), "failed to get clock\n");
+ goto err_pmruntime;
+ }
+
+ port->uartclk = clk_get_rate(info->clk);
+ }
+ /* If current-speed was set, then try not to change it. */
+ if (of_property_read_u32(np, "current-speed", &spd) == 0)
+ port->custom_divisor = port->uartclk / (16 * spd);
+
/* Compatibility with the deprecated pxa driver and 8250_pxa drivers. */
if (of_device_is_compatible(np, "mrvl,mmp-uart"))
port->regshift = 2;
- /* Check for registers offset within the devices address range */
- if (of_property_read_u32(np, "reg-shift", &prop) == 0)
- port->regshift = prop;
-
- /* Check for fifo size */
- if (of_property_read_u32(np, "fifo-size", &prop) == 0)
- port->fifosize = prop;
-
- /* Check for a fixed line number */
- ret = of_alias_get_id(np, "serial");
- if (ret >= 0)
- port->line = ret;
-
- irq = of_irq_get(np, 0);
- if (irq < 0) {
- if (irq == -EPROBE_DEFER) {
- ret = -EPROBE_DEFER;
- goto err_pmruntime;
- }
- /* IRQ support not mandatory */
- irq = 0;
- }
-
- port->irq = irq;
-
info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
if (IS_ERR(info->rst)) {
ret = PTR_ERR(info->rst);
@@ -183,12 +129,6 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
goto err_pmruntime;
port->type = type;
- port->uartclk = clk;
-
- if (of_property_read_bool(np, "no-loopback-test"))
- port->flags |= UPF_SKIP_TEST;
-
- port->dev = &ofdev->dev;
port->rs485_config = serial8250_em485_config;
port->rs485_supported = serial8250_em485_supported;
up->rs485_start_tx = serial8250_em485_start_tx;
@@ -280,7 +220,6 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
platform_set_drvdata(ofdev, info);
return 0;
err_dispose:
- irq_dispose_mapping(port8250.port.irq);
pm_runtime_put_sync(&ofdev->dev);
pm_runtime_disable(&ofdev->dev);
err_free:
--
2.43.0.rc1.1.gbec44491f096
next prev parent reply other threads:[~2024-02-21 18:35 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-21 18:31 [rft, PATCH v1 00/14] serial: Add a helper to parse device properties and more Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 01/14] serial: core: Move struct uart_port::quirks closer to possible values Andy Shevchenko
2024-02-21 18:54 ` Hugo Villeneuve
2024-02-21 19:04 ` Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 02/14] serial: core: Add UPIO_UNSET constant for unset port type Andy Shevchenko
2024-02-21 18:47 ` Florian Fainelli
2024-02-21 18:53 ` Andy Shevchenko
2024-02-22 6:58 ` Jiri Slaby
2024-02-22 13:21 ` Andy Shevchenko
2024-02-23 5:42 ` Jiri Slaby
2024-02-23 14:59 ` Andy Shevchenko
2024-02-26 14:17 ` Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 03/14] serial: port: Introduce a common helper to read properties Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 04/14] serial: 8250_aspeed_vuart: Switch to use uart_read_port_properties() Andy Shevchenko
2024-02-26 4:13 ` Andrew Jeffery
2024-02-21 18:31 ` [PATCH v1 05/14] serial: 8250_bcm2835aux: " Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 06/14] serial: 8250_bcm7271: " Andy Shevchenko
2024-02-23 4:14 ` kernel test robot
2024-02-23 15:01 ` Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 07/14] serial: 8250_dw: " Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 08/14] serial: 8250_ingenic: " Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 09/14] serial: 8250_lpc18xx: " Andy Shevchenko
2024-02-21 18:31 ` Andy Shevchenko [this message]
2024-02-22 0:37 ` [PATCH v1 10/14] serial: 8250_of: " Andrew Jeffery
2024-02-22 13:23 ` Andy Shevchenko
2024-02-22 16:43 ` Andy Shevchenko
2024-02-22 16:47 ` Andy Shevchenko
2024-02-22 17:39 ` Florian Fainelli
2024-02-22 19:54 ` Florian Fainelli
2024-02-23 15:02 ` Andy Shevchenko
2024-02-26 4:12 ` Andrew Jeffery
2024-02-21 18:31 ` [PATCH v1 11/14] serial: 8250_omap: " Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 12/14] serial: 8250_pxa: " Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 13/14] serial: 8250_tegra: " Andy Shevchenko
2024-02-21 18:31 ` [PATCH v1 14/14] serial: 8250_uniphier: " Andy Shevchenko
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=20240221183442.4124354-11-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=alcooperx@gmail.com \
--cc=andi.shyti@linux.intel.com \
--cc=andrew@codeconstruct.com.au \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=hayashi.kunihiko@socionext.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=joel@jms.id.au \
--cc=jonathanh@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=paul@crapouillou.net \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=tglx@linutronix.de \
--cc=thierry.reding@gmail.com \
--cc=vz@mleia.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).