From: Greg Ungerer <gerg@linux-m68k.org>
To: linux-m68k@lists.linux-m68k.org
Cc: Greg Ungerer <gerg@linux-m68k.org>
Subject: [PATCH 01/13] serial: mcf: convert to use proper platform resources
Date: Tue, 18 Feb 2025 22:46:21 +1000 [thread overview]
Message-ID: <20250218125124.2692982-2-gerg@linux-m68k.org> (raw)
In-Reply-To: <20250218125124.2692982-1-gerg@linux-m68k.org>
The ColdFire SoC device setup code supplies a non-standard array of
hardware address information (memory address and IRQ) for initializing
the UARTS - which it does as a single blob. The mcf serial probe
function processes the whole set in one go from a single platform entry.
Convert this setup to use the proper resource structures, with one for
each UART present on a platform. Modify the probe function to process
a single platform device per call, and use the proper platform resource
API to get the memory and IRQ addresses. This results in the proper
entries now being present in /proc/iomem.
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
---
arch/m68k/coldfire/device.c | 221 +++++++++++++++++++++++++++-----
arch/m68k/include/asm/mcfuart.h | 12 +-
drivers/tty/serial/mcf.c | 49 +++----
3 files changed, 218 insertions(+), 64 deletions(-)
diff --git a/arch/m68k/coldfire/device.c b/arch/m68k/coldfire/device.c
index b6958ec2a220..8d7cec28f4d9 100644
--- a/arch/m68k/coldfire/device.c
+++ b/arch/m68k/coldfire/device.c
@@ -1,7 +1,7 @@
/*
* device.c -- common ColdFire SoC device support
*
- * (C) Copyright 2011, Greg Ungerer <gerg@uclinux.org>
+ * (C) Copyright 2011,2025 Greg Ungerer <gerg@linux-m68k.org>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
@@ -18,8 +18,8 @@
#include <asm/traps.h>
#include <asm/coldfire.h>
#include <asm/mcfsim.h>
-#include <asm/mcfuart.h>
#include <asm/mcfqspi.h>
+#include <linux/platform_device.h>
#include <linux/platform_data/edma.h>
#include <linux/platform_data/dma-mcf-edma.h>
#include <linux/platform_data/mmc-esdhc-mcf.h>
@@ -27,71 +27,205 @@
/*
* All current ColdFire parts contain from 2, 3, 4 or 10 UARTS.
*/
-static struct mcf_platform_uart mcf_uart_platform_data[] = {
+static struct resource mcf_uart0_resources[] = {
{
- .mapbase = MCFUART_BASE0,
- .irq = MCF_IRQ_UART0,
+ .start = MCFUART_BASE0,
+ .end = MCFUART_BASE0 + 0x80 - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = MCF_IRQ_UART0,
+ .end = MCF_IRQ_UART0,
+ .flags = IORESOURCE_IRQ,
},
+};
+static struct platform_device mcf_uart0 = {
+ .name = "mcfuart",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(mcf_uart0_resources),
+ .resource = mcf_uart0_resources,
+};
+
+#ifdef MCFUART_BASE1
+static struct resource mcf_uart1_resources[] = {
{
- .mapbase = MCFUART_BASE1,
- .irq = MCF_IRQ_UART1,
+ .start = MCFUART_BASE1,
+ .end = MCFUART_BASE1 + 0x80 - 1,
+ .flags = IORESOURCE_MEM,
},
+ {
+ .start = MCF_IRQ_UART1,
+ .end = MCF_IRQ_UART1,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+static struct platform_device mcf_uart1 = {
+ .name = "mcfuart",
+ .id = 1,
+ .num_resources = ARRAY_SIZE(mcf_uart1_resources),
+ .resource = mcf_uart1_resources,
+};
+#endif
#ifdef MCFUART_BASE2
+static struct resource mcf_uart2_resources[] = {
{
- .mapbase = MCFUART_BASE2,
- .irq = MCF_IRQ_UART2,
+ .start = MCFUART_BASE2,
+ .end = MCFUART_BASE2 + 0x80 - 1,
+ .flags = IORESOURCE_MEM,
},
+ {
+ .start = MCF_IRQ_UART2,
+ .end = MCF_IRQ_UART2,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+static struct platform_device mcf_uart2 = {
+ .name = "mcfuart",
+ .id = 2,
+ .num_resources = ARRAY_SIZE(mcf_uart2_resources),
+ .resource = mcf_uart2_resources,
+};
#endif
#ifdef MCFUART_BASE3
+static struct resource mcf_uart3_resources[] = {
+ {
+ .start = MCFUART_BASE3,
+ .end = MCFUART_BASE3 + 0x80 - 1,
+ .flags = IORESOURCE_MEM,
+ },
{
- .mapbase = MCFUART_BASE3,
- .irq = MCF_IRQ_UART3,
+ .start = MCF_IRQ_UART3,
+ .end = MCF_IRQ_UART3,
+ .flags = IORESOURCE_IRQ,
},
+};
+static struct platform_device mcf_uart3 = {
+ .name = "mcfuart",
+ .id = 3,
+ .num_resources = ARRAY_SIZE(mcf_uart3_resources),
+ .resource = mcf_uart3_resources,
+};
#endif
#ifdef MCFUART_BASE4
+static struct resource mcf_uart4_resources[] = {
{
- .mapbase = MCFUART_BASE4,
- .irq = MCF_IRQ_UART4,
+ .start = MCFUART_BASE4,
+ .end = MCFUART_BASE4 + 0x80 - 1,
+ .flags = IORESOURCE_MEM,
},
+ {
+ .start = MCF_IRQ_UART4,
+ .end = MCF_IRQ_UART4,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+static struct platform_device mcf_uart4 = {
+ .name = "mcfuart",
+ .id = 4,
+ .num_resources = ARRAY_SIZE(mcf_uart4_resources),
+ .resource = mcf_uart4_resources,
+};
#endif
#ifdef MCFUART_BASE5
+static struct resource mcf_uart5_resources[] = {
{
- .mapbase = MCFUART_BASE5,
- .irq = MCF_IRQ_UART5,
+ .start = MCFUART_BASE5,
+ .end = MCFUART_BASE5 + 0x80 - 1,
+ .flags = IORESOURCE_MEM,
},
+ {
+ .start = MCF_IRQ_UART5,
+ .end = MCF_IRQ_UART5,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+static struct platform_device mcf_uart5 = {
+ .name = "mcfuart",
+ .id = 5,
+ .num_resources = ARRAY_SIZE(mcf_uart5_resources),
+ .resource = mcf_uart5_resources,
+};
#endif
#ifdef MCFUART_BASE6
+static struct resource mcf_uart6_resources[] = {
{
- .mapbase = MCFUART_BASE6,
- .irq = MCF_IRQ_UART6,
+ .start = MCFUART_BASE6,
+ .end = MCFUART_BASE6 + 0x80 - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = MCF_IRQ_UART6,
+ .end = MCF_IRQ_UART6,
+ .flags = IORESOURCE_IRQ,
},
+};
+static struct platform_device mcf_uart6 = {
+ .name = "mcfuart",
+ .id = 6,
+ .num_resources = ARRAY_SIZE(mcf_uart6_resources),
+ .resource = mcf_uart6_resources,
+};
#endif
#ifdef MCFUART_BASE7
+static struct resource mcf_uart7_resources[] = {
+ {
+ .start = MCFUART_BASE7,
+ .end = MCFUART_BASE7 + 0x80 - 1,
+ .flags = IORESOURCE_MEM,
+ },
{
- .mapbase = MCFUART_BASE7,
- .irq = MCF_IRQ_UART7,
+ .start = MCF_IRQ_UART7,
+ .end = MCF_IRQ_UART7,
+ .flags = IORESOURCE_IRQ,
},
+};
+static struct platform_device mcf_uart7 = {
+ .name = "mcfuart",
+ .id = 7,
+ .num_resources = ARRAY_SIZE(mcf_uart7_resources),
+ .resource = mcf_uart7_resources,
+};
#endif
#ifdef MCFUART_BASE8
+static struct resource mcf_uart8_resources[] = {
+ {
+ .start = MCFUART_BASE8,
+ .end = MCFUART_BASE8 + 0x80 - 1,
+ .flags = IORESOURCE_MEM,
+ },
{
- .mapbase = MCFUART_BASE8,
- .irq = MCF_IRQ_UART8,
+ .start = MCF_IRQ_UART8,
+ .end = MCF_IRQ_UART8,
+ .flags = IORESOURCE_IRQ,
},
+};
+static struct platform_device mcf_uart8 = {
+ .name = "mcfuart",
+ .id = 8,
+ .num_resources = ARRAY_SIZE(mcf_uart8_resources),
+ .resource = mcf_uart8_resources,
+};
#endif
#ifdef MCFUART_BASE9
+static struct resource mcf_uart9_resources[] = {
{
- .mapbase = MCFUART_BASE9,
- .irq = MCF_IRQ_UART9,
+ .start = MCFUART_BASE9,
+ .end = MCFUART_BASE9 + 0x80 - 1,
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .start = MCF_IRQ_UART9,
+ .end = MCF_IRQ_UART9,
+ .flags = IORESOURCE_IRQ,
},
-#endif
- { },
};
-
-static struct platform_device mcf_uart = {
+static struct platform_device mcf_uart9 = {
.name = "mcfuart",
- .id = 0,
- .dev.platform_data = mcf_uart_platform_data,
+ .id = 9,
+ .num_resources = ARRAY_SIZE(mcf_uart9_resources),
+ .resource = mcf_uart9_resources,
};
+#endif
#ifdef MCFFEC_BASE0
@@ -623,7 +757,34 @@ static struct platform_device mcf_flexcan0 = {
#endif /* MCFFLEXCAN_SIZE */
static struct platform_device *mcf_devices[] __initdata = {
- &mcf_uart,
+ &mcf_uart0,
+#ifdef MCFUART_BASE1
+ &mcf_uart1,
+#endif
+#ifdef MCFUART_BASE2
+ &mcf_uart2,
+#endif
+#ifdef MCFUART_BASE3
+ &mcf_uart3,
+#endif
+#ifdef MCFUART_BASE4
+ &mcf_uart4,
+#endif
+#ifdef MCFUART_BASE5
+ &mcf_uart5,
+#endif
+#ifdef MCFUART_BASE6
+ &mcf_uart6,
+#endif
+#ifdef MCFUART_BASE7
+ &mcf_uart7,
+#endif
+#ifdef MCFUART_BASE8
+ &mcf_uart8,
+#endif
+#ifdef MCFUART_BASE9
+ &mcf_uart9,
+#endif
#ifdef MCFFEC_BASE0
&mcf_fec0,
#endif
diff --git a/arch/m68k/include/asm/mcfuart.h b/arch/m68k/include/asm/mcfuart.h
index a1f35352f328..8bf626af3817 100644
--- a/arch/m68k/include/asm/mcfuart.h
+++ b/arch/m68k/include/asm/mcfuart.h
@@ -4,7 +4,7 @@
/*
* mcfuart.h -- ColdFire internal UART support defines.
*
- * (C) Copyright 1999-2003, Greg Ungerer (gerg@snapgear.com)
+ * (C) Copyright 1999-2003, 2025 Greg Ungerer (gerg@linux-m68k.org)
* (C) Copyright 2000, Lineo Inc. (www.lineo.com)
*/
@@ -13,16 +13,6 @@
#define mcfuart_h
/****************************************************************************/
-#include <linux/serial_core.h>
-#include <linux/platform_device.h>
-
-struct mcf_platform_uart {
- unsigned long mapbase; /* Physical address base */
- void __iomem *membase; /* Virtual address if mapped */
- unsigned int irq; /* Interrupt vector */
- unsigned int uartclk; /* UART clock rate */
-};
-
/*
* Define the ColdFire UART register set addresses.
*/
diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
index 93e7dda4d39a..fd8cf3399855 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -4,7 +4,7 @@
/*
* mcf.c -- Freescale ColdFire UART driver
*
- * (C) Copyright 2003-2007, Greg Ungerer <gerg@uclinux.org>
+ * (C) Copyright 2003-2007,2025 Greg Ungerer <gerg@linux-m68k.org>
*/
/****************************************************************************/
@@ -570,31 +570,34 @@ static struct uart_driver mcf_driver = {
static int mcf_probe(struct platform_device *pdev)
{
- struct mcf_platform_uart *platp = dev_get_platdata(&pdev->dev);
struct uart_port *port;
- int i;
+ struct resource *res;
- for (i = 0; ((i < MCF_MAXPORTS) && (platp[i].mapbase)); i++) {
- port = &mcf_ports[i].port;
+ if (pdev->id >= MCF_MAXPORTS)
+ return -ENODEV;
+ port = &mcf_ports[pdev->id].port;
- port->line = i;
- port->type = PORT_MCF;
- port->mapbase = platp[i].mapbase;
- port->membase = (platp[i].membase) ? platp[i].membase :
- (unsigned char __iomem *) platp[i].mapbase;
- port->dev = &pdev->dev;
- port->iotype = SERIAL_IO_MEM;
- port->irq = platp[i].irq;
- port->uartclk = MCF_BUSCLK;
- port->ops = &mcf_uart_ops;
- port->flags = UPF_BOOT_AUTOCONF;
- port->rs485_config = mcf_config_rs485;
- port->rs485_supported = mcf_rs485_supported;
- port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MCF_CONSOLE);
-
- uart_add_one_port(&mcf_driver, port);
- }
+ port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+ if (IS_ERR(port->membase))
+ return PTR_ERR(port->membase);
+ port->mapbase = res->start;
+
+ port->irq = platform_get_irq(pdev, 0);
+ if (port->irq < 0)
+ return port->irq;
+ port->line = pdev->id;
+ port->type = PORT_MCF;
+ port->dev = &pdev->dev;
+ port->iotype = SERIAL_IO_MEM;
+ port->uartclk = MCF_BUSCLK;
+ port->ops = &mcf_uart_ops;
+ port->flags = UPF_BOOT_AUTOCONF;
+ port->rs485_config = mcf_config_rs485;
+ port->rs485_supported = mcf_rs485_supported;
+ port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MCF_CONSOLE);
+
+ uart_add_one_port(&mcf_driver, port);
return 0;
}
@@ -654,7 +657,7 @@ static void __exit mcf_exit(void)
module_init(mcf_init);
module_exit(mcf_exit);
-MODULE_AUTHOR("Greg Ungerer <gerg@uclinux.org>");
+MODULE_AUTHOR("Greg Ungerer <gerg@linux-m68k.org>");
MODULE_DESCRIPTION("Freescale ColdFire UART driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:mcfuart");
--
2.43.0
next prev parent reply other threads:[~2025-02-18 12:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 12:46 [PATCH 00/13] m68k: coldfire: proof-of-concept devicetree Greg Ungerer
2025-02-18 12:46 ` Greg Ungerer [this message]
2025-02-18 12:46 ` [PATCH 02/13] serial: mcf: add devicetree support Greg Ungerer
2025-02-18 12:46 ` [PATCH 03/13] net: fec: add device tree support for ColdFire FEC Greg Ungerer
2025-02-19 7:05 ` Krzysztof Kozlowski
2025-02-19 13:25 ` Greg Ungerer
2025-02-18 12:46 ` [PATCH 04/13] m68k: coldfire: enable common clock framework Greg Ungerer
2025-02-18 12:46 ` [PATCH 05/13] m68k: coldfire: support devicetree binding for intc-simr Greg Ungerer
2025-02-18 12:46 ` [PATCH 06/13] m68k: coldfire: support devicetree binding for intc controller Greg Ungerer
2025-02-18 12:46 ` [PATCH 07/13] m68k: coldfire: support devicetree binding for intc-2 controller Greg Ungerer
2025-02-18 12:46 ` [PATCH 08/13] m68k: coldfire: add devicetree for mcf5208-evb platform Greg Ungerer
2025-02-18 12:46 ` [PATCH 09/13] m68k: coldfire: add devicetree for mcf5475-evb platform Greg Ungerer
2025-02-19 7:06 ` Krzysztof Kozlowski
2025-02-19 8:23 ` Greg Ungerer
2025-02-19 8:26 ` Krzysztof Kozlowski
2025-02-19 21:58 ` Greg Ungerer
2025-02-18 12:46 ` [PATCH 10/13] m68k: implement an embedded devicetree for nonmmu Greg Ungerer
2025-02-20 14:06 ` Geert Uytterhoeven
2025-02-23 14:25 ` Greg Ungerer
2025-02-18 12:46 ` [PATCH 11/13] m68k: implement an embedded devicetree for mm targets Greg Ungerer
2025-02-18 12:46 ` [PATCH 12/13] m68k: coldfire: disable platform device tree entries Greg Ungerer
2025-02-18 12:46 ` [PATCH 13/13] m68k: coldfire: enable devicetree use Greg Ungerer
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=20250218125124.2692982-2-gerg@linux-m68k.org \
--to=gerg@linux-m68k.org \
--cc=linux-m68k@lists.linux-m68k.org \
/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