mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH] ARM: move reserve_lp[012] handling into affected machines
@ 2026-05-11  1:14 Ethan Nelson-Moore
  2026-06-14  2:20 ` Ethan Nelson-Moore
  0 siblings, 1 reply; 3+ messages in thread
From: Ethan Nelson-Moore @ 2026-05-11  1:14 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: Russell King, Ethan Nelson-Moore, Andrew Morton, Jiri Bohac

arch/arm/kernel/setup.c contains code to reserve lp0/1/2 I/O ports for
machines that can't possibly have these ports. This code is only used
by netwinder and footbridge, and is small enough that it can just be
moved into these machines. Do so to make the setup code more generic
and the machine code more self-contained.

This patch is an RFC because I'm not sure if using .init_early is
actually necessary. I did it to match the place the original code was
called as closely as possible. Can anyone weigh in on this?

Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com>
---
 arch/arm/include/asm/mach/arch.h        |  3 --
 arch/arm/kernel/setup.c                 | 37 -------------------
 arch/arm/mach-footbridge/netwinder-hw.c | 48 ++++++++++++++++++-------
 arch/arm/mach-rpc/riscpc.c              | 30 ++++++++++++++--
 4 files changed, 63 insertions(+), 55 deletions(-)

diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
index 2b18a258204d..fc5abdd2fe88 100644
--- a/arch/arm/include/asm/mach/arch.h
+++ b/arch/arm/include/asm/mach/arch.h
@@ -37,9 +37,6 @@ struct machine_desc {
 	unsigned int		video_start;	/* start of video RAM	*/
 	unsigned int		video_end;	/* end of video RAM	*/
 
-	unsigned char		reserve_lp0 :1;	/* never has lp0	*/
-	unsigned char		reserve_lp1 :1;	/* never has lp1	*/
-	unsigned char		reserve_lp2 :1;	/* never has lp2	*/
 	enum reboot_mode	reboot_mode;	/* default restart mode	*/
 	unsigned		l2c_aux_val;	/* L2 cache aux value	*/
 	unsigned		l2c_aux_mask;	/* L2 cache aux mask	*/
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 0bfd66c7ada0..5416ef7b4f31 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -8,7 +8,6 @@
 #include <linux/export.h>
 #include <linux/kernel.h>
 #include <linux/stddef.h>
-#include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/utsname.h>
 #include <linux/initrd.h>
@@ -185,31 +184,6 @@ static struct resource mem_res[] = {
 #define kernel_code mem_res[1]
 #define kernel_data mem_res[2]
 
-static struct resource io_res[] = {
-	{
-		.name = "reserved",
-		.start = 0x3bc,
-		.end = 0x3be,
-		.flags = IORESOURCE_IO | IORESOURCE_BUSY
-	},
-	{
-		.name = "reserved",
-		.start = 0x378,
-		.end = 0x37f,
-		.flags = IORESOURCE_IO | IORESOURCE_BUSY
-	},
-	{
-		.name = "reserved",
-		.start = 0x278,
-		.end = 0x27f,
-		.flags = IORESOURCE_IO | IORESOURCE_BUSY
-	}
-};
-
-#define lp0 io_res[0]
-#define lp1 io_res[1]
-#define lp2 io_res[2]
-
 static const char *proc_arch[] = {
 	"undefined/unknown",
 	"3",
@@ -909,17 +883,6 @@ static void __init request_standard_resources(const struct machine_desc *mdesc)
 		video_ram.end   = mdesc->video_end;
 		request_resource(&iomem_resource, &video_ram);
 	}
-
-	/*
-	 * Some machines don't have the possibility of ever
-	 * possessing lp0, lp1 or lp2
-	 */
-	if (mdesc->reserve_lp0)
-		request_resource(&ioport_resource, &lp0);
-	if (mdesc->reserve_lp1)
-		request_resource(&ioport_resource, &lp1);
-	if (mdesc->reserve_lp2)
-		request_resource(&ioport_resource, &lp2);
 }
 
 #if defined(CONFIG_VGA_CONSOLE)
diff --git a/arch/arm/mach-footbridge/netwinder-hw.c b/arch/arm/mach-footbridge/netwinder-hw.c
index ab17ba916d47..6a4f15526189 100644
--- a/arch/arm/mach-footbridge/netwinder-hw.c
+++ b/arch/arm/mach-footbridge/netwinder-hw.c
@@ -616,23 +616,47 @@ static int __init nw_hw_init(void)
 
 __initcall(nw_hw_init);
 
+/* The NetWinder never has lp0 or lp2 */
+static struct resource reserved_resources[] = {
+	{
+		/* lp0 */
+		.name = "reserved",
+		.start = 0x3bc,
+		.end = 0x3be,
+		.flags = IORESOURCE_IO | IORESOURCE_BUSY
+	},
+	{
+		/* lp2 */
+		.name = "reserved",
+		.start = 0x278,
+		.end = 0x27f,
+		.flags = IORESOURCE_IO | IORESOURCE_BUSY
+	},
+};
+
 /*
  * Older NeTTroms either do not provide a parameters
  * page, or they don't supply correct information in
  * the parameter page.
  */
-static void __init
-fixup_netwinder(struct tag *tags, char **cmdline)
+static void __init netwinder_init_early(void)
 {
-#ifdef CONFIG_ISAPNP
-	extern int isapnp_disable;
+	int i;
 
-	/*
-	 * We must not use the kernels ISAPnP code
-	 * on the NetWinder - it will reset the settings
-	 * for the WaveArtist chip and render it inoperable.
-	 */
-	isapnp_disable = 1;
+	for (i = 0; i < ARRAY_SIZE(reserved_resources); i++)
+		request_resource(&ioport_resource, &reserved_resources[i]);
+
+#ifdef CONFIG_ISAPNP
+	{
+		extern int isapnp_disable;
+
+		/*
+		 * We must not use the kernels ISAPnP code
+		 * on the NetWinder - it will reset the settings
+		 * for the WaveArtist chip and render it inoperable.
+		 */
+		isapnp_disable = 1;
+	}
 #endif
 }
 
@@ -763,9 +787,7 @@ MACHINE_START(NETWINDER, "Rebel-NetWinder")
 	.atag_offset	= 0x100,
 	.video_start	= 0x000a0000,
 	.video_end	= 0x000bffff,
-	.reserve_lp0	= 1,
-	.reserve_lp2	= 1,
-	.fixup		= fixup_netwinder,
+	.init_early	= netwinder_init_early,
 	.map_io		= footbridge_map_io,
 	.nr_irqs	= FOOTBRIDGE_NR_IRQS,
 	.init_irq	= footbridge_init_irq,
diff --git a/arch/arm/mach-rpc/riscpc.c b/arch/arm/mach-rpc/riscpc.c
index 14d78b7f9493..6d764a660474 100644
--- a/arch/arm/mach-rpc/riscpc.c
+++ b/arch/arm/mach-rpc/riscpc.c
@@ -16,6 +16,7 @@
 #include <linux/serial_8250.h>
 #include <linux/ata_platform.h>
 #include <linux/io.h>
+#include <linux/ioport.h>
 #include <linux/i2c.h>
 #include <linux/reboot.h>
 
@@ -185,6 +186,32 @@ static struct i2c_board_info i2c_rtc = {
 	I2C_BOARD_INFO("pcf8583", 0x50)
 };
 
+/* The Risc PC never has lp0 or lp1 */
+static struct resource reserved_resources[] = {
+	{
+		/* lp0 */
+		.name = "reserved",
+		.start = 0x3bc,
+		.end = 0x3be,
+		.flags = IORESOURCE_IO | IORESOURCE_BUSY
+	},
+	{
+		/* lp1 */
+		.name = "reserved",
+		.start = 0x378,
+		.end = 0x37f,
+		.flags = IORESOURCE_IO | IORESOURCE_BUSY
+	},
+};
+
+static void __init rpc_init_early(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(reserved_resources); i++)
+		request_resource(&ioport_resource, &reserved_resources[i]);
+}
+
 static int __init rpc_init(void)
 {
 	i2c_register_board_info(0, &i2c_rtc, 1);
@@ -208,8 +235,7 @@ void ioc_timer_init(void);
 MACHINE_START(RISCPC, "Acorn-RiscPC")
 	/* Maintainer: Russell King */
 	.atag_offset	= 0x100,
-	.reserve_lp0	= 1,
-	.reserve_lp1	= 1,
+	.init_early	= rpc_init_early,
 	.map_io		= rpc_map_io,
 	.nr_irqs	= RPC_NR_IRQS,
 	.init_irq	= rpc_init_irq,
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] ARM: move reserve_lp[012] handling into affected machines
  2026-05-11  1:14 [RFC PATCH] ARM: move reserve_lp[012] handling into affected machines Ethan Nelson-Moore
@ 2026-06-14  2:20 ` Ethan Nelson-Moore
  2026-06-15 12:41   ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Ethan Nelson-Moore @ 2026-06-14  2:20 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: Russell King, Andrew Morton, Jiri Bohac, Linus Walleij, Arnd Bergmann

On Sun, May 10, 2026 at 6:15 PM Ethan Nelson-Moore
<enelsonmoore@gmail.com> wrote:
> arch/arm/kernel/setup.c contains code to reserve lp0/1/2 I/O ports for
> machines that can't possibly have these ports. This code is only used
> by netwinder and footbridge, and is small enough that it can just be
> moved into these machines. Do so to make the setup code more generic
> and the machine code more self-contained.
>
> This patch is an RFC because I'm not sure if using .init_early is
> actually necessary. I did it to match the place the original code was
> called as closely as possible. Can anyone weigh in on this?

Hi, everyone,

Gentle ping (+ cc Arnd, LinusW) - anyone have any thoughts on this?

I meant rpc and footbridge in the commit message - I'll fix it in a
future revision.

Ethan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] ARM: move reserve_lp[012] handling into affected machines
  2026-06-14  2:20 ` Ethan Nelson-Moore
@ 2026-06-15 12:41   ` Linus Walleij
  0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2026-06-15 12:41 UTC (permalink / raw)
  To: Ethan Nelson-Moore
  Cc: linux-arm-kernel, linux-kernel, Russell King, Andrew Morton,
	Jiri Bohac, Arnd Bergmann

On Sun, Jun 14, 2026 at 4:20 AM Ethan Nelson-Moore
<enelsonmoore@gmail.com> wrote:
> On Sun, May 10, 2026 at 6:15 PM Ethan Nelson-Moore
> <enelsonmoore@gmail.com> wrote:
> > arch/arm/kernel/setup.c contains code to reserve lp0/1/2 I/O ports for
> > machines that can't possibly have these ports. This code is only used
> > by netwinder and footbridge, and is small enough that it can just be
> > moved into these machines. Do so to make the setup code more generic
> > and the machine code more self-contained.
> >
> > This patch is an RFC because I'm not sure if using .init_early is
> > actually necessary. I did it to match the place the original code was
> > called as closely as possible. Can anyone weigh in on this?
>
> Hi, everyone,
>
> Gentle ping (+ cc Arnd, LinusW) - anyone have any thoughts on this?

My general idea about this and the other patch for sparse IRQs
was that I wanted to drag my Footbridge (NetWinder) out of the
closet and boot with these patches to make sure they work.

I just haven't had time, and it got buried pretty deep in there
I think...

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-15 12:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-11  1:14 [RFC PATCH] ARM: move reserve_lp[012] handling into affected machines Ethan Nelson-Moore
2026-06-14  2:20 ` Ethan Nelson-Moore
2026-06-15 12:41   ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®