From: Greg Ungerer <gerg@linux-m68k.org>
To: linux-m68k@lists.linux-m68k.org, linux-serial@vger.kernel.org
Cc: Greg Ungerer <gerg@linux-m68k.org>
Subject: [PATCH 2/5] serial: mcf: convert to use proper platform resources
Date: Tue, 13 Oct 2026 22:07:00 +1000 [thread overview]
Message-ID: <20261013120831.1046590-3-gerg@linux-m68k.org> (raw)
In-Reply-To: <20261013120831.1046590-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 | 179 +++++++++++++++++++++++---------
arch/m68k/include/asm/mcfuart.h | 10 --
drivers/tty/serial/mcf.c | 45 ++++----
3 files changed, 154 insertions(+), 80 deletions(-)
diff --git a/arch/m68k/coldfire/device.c b/arch/m68k/coldfire/device.c
index 9a0258acd998..e32bc3322c97 100644
--- a/arch/m68k/coldfire/device.c
+++ b/arch/m68k/coldfire/device.c
@@ -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,125 @@
/*
* All current ColdFire parts contain from 2, 3, 4 or 10 UARTS.
*/
-static struct mcf_platform_uart mcf_uart_platform_data[] = {
- {
- .mapbase = MCFUART_BASE0,
- .irq = MCF_IRQ_UART0,
- },
- {
- .mapbase = MCFUART_BASE1,
- .irq = MCF_IRQ_UART1,
- },
+static struct resource mcf_uart0_resources[] = {
+ DEFINE_RES_MEM(MCFUART_BASE0, 0x80),
+ DEFINE_RES_IRQ(MCF_IRQ_UART0),
+};
+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[] = {
+ DEFINE_RES_MEM(MCFUART_BASE1, 0x80),
+ DEFINE_RES_IRQ(MCF_IRQ_UART1),
+};
+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
- {
- .mapbase = MCFUART_BASE2,
- .irq = MCF_IRQ_UART2,
- },
+static struct resource mcf_uart2_resources[] = {
+ DEFINE_RES_MEM(MCFUART_BASE2, 0x80),
+ DEFINE_RES_IRQ(MCF_IRQ_UART2),
+};
+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
- {
- .mapbase = MCFUART_BASE3,
- .irq = MCF_IRQ_UART3,
- },
+static struct resource mcf_uart3_resources[] = {
+ DEFINE_RES_MEM(MCFUART_BASE3, 0x80),
+ DEFINE_RES_IRQ(MCF_IRQ_UART3),
+};
+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
- {
- .mapbase = MCFUART_BASE4,
- .irq = MCF_IRQ_UART4,
- },
+static struct resource mcf_uart4_resources[] = {
+ DEFINE_RES_MEM(MCFUART_BASE4, 0x80),
+ DEFINE_RES_IRQ(MCF_IRQ_UART4),
+};
+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
- {
- .mapbase = MCFUART_BASE5,
- .irq = MCF_IRQ_UART5,
- },
+static struct resource mcf_uart5_resources[] = {
+ DEFINE_RES_MEM(MCFUART_BASE5, 0x80),
+ DEFINE_RES_IRQ(MCF_IRQ_UART5),
+};
+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
- {
- .mapbase = MCFUART_BASE6,
- .irq = MCF_IRQ_UART6,
- },
+static struct resource mcf_uart6_resources[] = {
+ DEFINE_RES_MEM(MCFUART_BASE6, 0x80),
+ DEFINE_RES_IRQ(MCF_IRQ_UART6),
+};
+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
- {
- .mapbase = MCFUART_BASE7,
- .irq = MCF_IRQ_UART7,
- },
+static struct resource mcf_uart7_resources[] = {
+ DEFINE_RES_MEM(MCFUART_BASE7, 0x80),
+ DEFINE_RES_IRQ(MCF_IRQ_UART7),
+};
+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
- {
- .mapbase = MCFUART_BASE8,
- .irq = MCF_IRQ_UART8,
- },
+static struct resource mcf_uart8_resources[] = {
+ DEFINE_RES_MEM(MCFUART_BASE8, 0x80),
+ DEFINE_RES_IRQ(MCF_IRQ_UART8),
+};
+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
- {
- .mapbase = MCFUART_BASE9,
- .irq = MCF_IRQ_UART9,
- },
-#endif
- { },
+static struct resource mcf_uart9_resources[] = {
+ DEFINE_RES_MEM(MCFUART_BASE9, 0x80),
+ DEFINE_RES_IRQ(MCF_IRQ_UART9),
};
-
-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 +677,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..c80b022c1ebb 100644
--- a/arch/m68k/include/asm/mcfuart.h
+++ b/arch/m68k/include/asm/mcfuart.h
@@ -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 2b862dfe39ab..3651910dff99 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -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;
}
--
2.55.0
next prev parent reply other threads:[~2026-10-13 12:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 12:06 [PATCH 0/5] serial: mcf: add devicetree support Greg Ungerer
2026-10-13 12:06 ` [PATCH 1/5] serial: mcf: update author email address Greg Ungerer
2026-10-13 12:14 ` sashiko-bot
2026-10-13 12:07 ` Greg Ungerer [this message]
2026-10-13 12:07 ` [PATCH 3/5] serial: mcf: dynamically allocate memory Greg Ungerer
2026-10-13 12:07 ` [PATCH 4/5] dt-bindings: serial: create binding for mcf-uart Greg Ungerer
2026-10-13 12:07 ` [PATCH 5/5] serial: mcf: add devicetree support 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=20261013120831.1046590-3-gerg@linux-m68k.org \
--to=gerg@linux-m68k.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-serial@vger.kernel.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