From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Florian Fainelli <florian.fainelli@broadcom.com>, 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>, "Broadcom internal kernel review list" <bcm-kernel-feedback-list@broadcom.com>, "Ray Jui" <rjui@broadcom.com>, "Scott Branden" <sbranden@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 v3 04/14] serial: 8250_aspeed_vuart: Switch to use uart_read_port_properties() Date: Mon, 4 Mar 2024 14:27:05 +0200 [thread overview] Message-ID: <20240304123035.758700-5-andriy.shevchenko@linux.intel.com> (raw) In-Reply-To: <20240304123035.758700-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> Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au> --- drivers/tty/serial/8250/8250_aspeed_vuart.c | 50 +++++++-------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c index 8c2aaf7af7b7..53d8eee9b1c8 100644 --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c @@ -419,8 +419,8 @@ static int aspeed_vuart_probe(struct platform_device *pdev) struct aspeed_vuart *vuart; struct device_node *np; struct resource *res; - u32 clk, prop, sirq[2]; int rc, sirq_polarity; + u32 prop, sirq[2]; struct clk *vclk; np = pdev->dev.of_node; @@ -447,53 +447,35 @@ static int aspeed_vuart_probe(struct platform_device *pdev) port.port.status = UPSTAT_SYNC_FIFO; port.port.dev = &pdev->dev; port.port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE); + port.port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_FIXED_PORT | UPF_FIXED_TYPE | + UPF_NO_THRE_TEST; port.bugs |= UART_BUG_TXRACE; rc = sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); if (rc < 0) return rc; - if (of_property_read_u32(np, "clock-frequency", &clk)) { + rc = uart_read_port_properties(&port.port); + if (rc) + goto err_sysfs_remove; + + /* Get clk rate through clk driver if present */ + if (!port.port.uartclk) { vclk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(vclk)) { rc = dev_err_probe(dev, PTR_ERR(vclk), "clk or clock-frequency not defined\n"); goto err_sysfs_remove; } - clk = clk_get_rate(vclk); + port.port.uartclk = clk_get_rate(vclk); } /* If current-speed was set, then try not to change it. */ if (of_property_read_u32(np, "current-speed", &prop) == 0) - port.port.custom_divisor = clk / (16 * prop); + port.port.custom_divisor = port.port.uartclk / (16 * prop); - /* Check for shifted address mapping */ - if (of_property_read_u32(np, "reg-offset", &prop) == 0) - port.port.mapbase += prop; - - /* Check for registers offset within the devices address range */ - if (of_property_read_u32(np, "reg-shift", &prop) == 0) - port.port.regshift = prop; - - /* Check for fifo size */ - if (of_property_read_u32(np, "fifo-size", &prop) == 0) - port.port.fifosize = prop; - - /* Check for a fixed line number */ - rc = of_alias_get_id(np, "serial"); - if (rc >= 0) - port.port.line = rc; - - port.port.irq = irq_of_parse_and_map(np, 0); port.port.handle_irq = aspeed_vuart_handle_irq; - port.port.iotype = UPIO_MEM; port.port.type = PORT_ASPEED_VUART; - port.port.uartclk = clk; - port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP - | UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_NO_THRE_TEST; - - if (of_property_read_bool(np, "no-loopback-test")) - port.port.flags |= UPF_SKIP_TEST; if (port.port.fifosize) port.capabilities = UART_CAP_FIFO; @@ -503,7 +485,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev) rc = serial8250_register_8250_port(&port); if (rc < 0) - goto err_clk_disable; + goto err_sysfs_remove; vuart->line = rc; vuart->port = serial8250_get_port(vuart->line); @@ -529,7 +511,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev) rc = aspeed_vuart_set_lpc_address(vuart, prop); if (rc < 0) { dev_err_probe(dev, rc, "invalid value in aspeed,lpc-io-reg property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } rc = of_property_read_u32_array(np, "aspeed,lpc-interrupts", sirq, 2); @@ -541,14 +523,14 @@ static int aspeed_vuart_probe(struct platform_device *pdev) rc = aspeed_vuart_set_sirq(vuart, sirq[0]); if (rc < 0) { dev_err_probe(dev, rc, "invalid sirq number in aspeed,lpc-interrupts property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } sirq_polarity = aspeed_vuart_map_irq_polarity(sirq[1]); if (sirq_polarity < 0) { rc = dev_err_probe(dev, sirq_polarity, "invalid sirq polarity in aspeed,lpc-interrupts property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } aspeed_vuart_set_sirq_polarity(vuart, sirq_polarity); @@ -559,8 +541,6 @@ static int aspeed_vuart_probe(struct platform_device *pdev) return 0; -err_clk_disable: - irq_dispose_mapping(port.port.irq); err_sysfs_remove: sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); return rc; -- 2.43.0.rc1.1.gbec44491f096
WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Florian Fainelli <florian.fainelli@broadcom.com>, 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>, "Broadcom internal kernel review list" <bcm-kernel-feedback-list@broadcom.com>, "Ray Jui" <rjui@broadcom.com>, "Scott Branden" <sbranden@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 v3 04/14] serial: 8250_aspeed_vuart: Switch to use uart_read_port_properties() Date: Mon, 4 Mar 2024 14:27:05 +0200 [thread overview] Message-ID: <20240304123035.758700-5-andriy.shevchenko@linux.intel.com> (raw) In-Reply-To: <20240304123035.758700-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> Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au> --- drivers/tty/serial/8250/8250_aspeed_vuart.c | 50 +++++++-------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c index 8c2aaf7af7b7..53d8eee9b1c8 100644 --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c @@ -419,8 +419,8 @@ static int aspeed_vuart_probe(struct platform_device *pdev) struct aspeed_vuart *vuart; struct device_node *np; struct resource *res; - u32 clk, prop, sirq[2]; int rc, sirq_polarity; + u32 prop, sirq[2]; struct clk *vclk; np = pdev->dev.of_node; @@ -447,53 +447,35 @@ static int aspeed_vuart_probe(struct platform_device *pdev) port.port.status = UPSTAT_SYNC_FIFO; port.port.dev = &pdev->dev; port.port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE); + port.port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_FIXED_PORT | UPF_FIXED_TYPE | + UPF_NO_THRE_TEST; port.bugs |= UART_BUG_TXRACE; rc = sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); if (rc < 0) return rc; - if (of_property_read_u32(np, "clock-frequency", &clk)) { + rc = uart_read_port_properties(&port.port); + if (rc) + goto err_sysfs_remove; + + /* Get clk rate through clk driver if present */ + if (!port.port.uartclk) { vclk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(vclk)) { rc = dev_err_probe(dev, PTR_ERR(vclk), "clk or clock-frequency not defined\n"); goto err_sysfs_remove; } - clk = clk_get_rate(vclk); + port.port.uartclk = clk_get_rate(vclk); } /* If current-speed was set, then try not to change it. */ if (of_property_read_u32(np, "current-speed", &prop) == 0) - port.port.custom_divisor = clk / (16 * prop); + port.port.custom_divisor = port.port.uartclk / (16 * prop); - /* Check for shifted address mapping */ - if (of_property_read_u32(np, "reg-offset", &prop) == 0) - port.port.mapbase += prop; - - /* Check for registers offset within the devices address range */ - if (of_property_read_u32(np, "reg-shift", &prop) == 0) - port.port.regshift = prop; - - /* Check for fifo size */ - if (of_property_read_u32(np, "fifo-size", &prop) == 0) - port.port.fifosize = prop; - - /* Check for a fixed line number */ - rc = of_alias_get_id(np, "serial"); - if (rc >= 0) - port.port.line = rc; - - port.port.irq = irq_of_parse_and_map(np, 0); port.port.handle_irq = aspeed_vuart_handle_irq; - port.port.iotype = UPIO_MEM; port.port.type = PORT_ASPEED_VUART; - port.port.uartclk = clk; - port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP - | UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_NO_THRE_TEST; - - if (of_property_read_bool(np, "no-loopback-test")) - port.port.flags |= UPF_SKIP_TEST; if (port.port.fifosize) port.capabilities = UART_CAP_FIFO; @@ -503,7 +485,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev) rc = serial8250_register_8250_port(&port); if (rc < 0) - goto err_clk_disable; + goto err_sysfs_remove; vuart->line = rc; vuart->port = serial8250_get_port(vuart->line); @@ -529,7 +511,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev) rc = aspeed_vuart_set_lpc_address(vuart, prop); if (rc < 0) { dev_err_probe(dev, rc, "invalid value in aspeed,lpc-io-reg property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } rc = of_property_read_u32_array(np, "aspeed,lpc-interrupts", sirq, 2); @@ -541,14 +523,14 @@ static int aspeed_vuart_probe(struct platform_device *pdev) rc = aspeed_vuart_set_sirq(vuart, sirq[0]); if (rc < 0) { dev_err_probe(dev, rc, "invalid sirq number in aspeed,lpc-interrupts property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } sirq_polarity = aspeed_vuart_map_irq_polarity(sirq[1]); if (sirq_polarity < 0) { rc = dev_err_probe(dev, sirq_polarity, "invalid sirq polarity in aspeed,lpc-interrupts property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } aspeed_vuart_set_sirq_polarity(vuart, sirq_polarity); @@ -559,8 +541,6 @@ static int aspeed_vuart_probe(struct platform_device *pdev) return 0; -err_clk_disable: - irq_dispose_mapping(port.port.irq); err_sysfs_remove: sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); return rc; -- 2.43.0.rc1.1.gbec44491f096 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-03-04 12:30 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-04 12:27 [PATCH v3 00/14] serial: Add a helper to parse device properties and more Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 01/14] serial: core: Move struct uart_port::quirks closer to possible values Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 02/14] serial: core: Add UPIO_UNKNOWN constant for unknown port type Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 03/14] serial: port: Introduce a common helper to read properties Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko [this message] 2024-03-04 12:27 ` [PATCH v3 04/14] serial: 8250_aspeed_vuart: Switch to use uart_read_port_properties() Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 05/14] serial: 8250_bcm2835aux: " Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 06/14] serial: 8250_bcm7271: " Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 07/14] serial: 8250_dw: " Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 08/14] serial: 8250_ingenic: " Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 09/14] serial: 8250_lpc18xx: " Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 10/14] serial: 8250_of: " Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 11/14] serial: 8250_omap: " Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 12/14] serial: 8250_pxa: " Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 13/14] serial: 8250_tegra: " Andy Shevchenko 2024-03-04 12:27 ` Andy Shevchenko 2024-03-04 12:27 ` [PATCH v3 14/14] serial: 8250_uniphier: " Andy Shevchenko 2024-03-04 12:27 ` 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=20240304123035.758700-5-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=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: linkBe 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.