* [PATCH] ARM: lpc32xx: only run arch_initcalls on LPC32xx hardware
@ 2026-07-12 20:56 Karl Mehltretter
2026-07-12 21:04 ` Arnd Bergmann
0 siblings, 1 reply; 2+ messages in thread
From: Karl Mehltretter @ 2026-07-12 20:56 UTC (permalink / raw)
To: Vladimir Zapolskiy, Piotr Wojtaszczyk
Cc: Arnd Bergmann, linux-arm-kernel, linux-kernel, Karl Mehltretter
lpc32xx_check_uid() and lpc32xx_pm_init() are arch_initcalls that poke
LPC32xx-only registers (the CLKPWR unique-ID and the EMC control
register). Since the multiplatform conversion they also run on other
ARCH_MULTI_V5 boards, where the access faults, e.g. on versatile:
Unable to handle kernel paging request at virtual address f4004130
PC is at lpc32xx_check_uid+0x2c/0x9c
Bail out of both unless we are running on an LPC32xx SoC, reusing the
machine's DT_MACHINE compatible list so the guard can't drift from it.
Fixes: 75bf1bd7d2f9 ("ARM: lpc32xx: allow multiplatform build")
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---
arch/arm/mach-lpc32xx/common.c | 10 ++++++++++
arch/arm/mach-lpc32xx/common.h | 2 ++
arch/arm/mach-lpc32xx/phy3250.c | 2 +-
arch/arm/mach-lpc32xx/pm.c | 3 +++
4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-lpc32xx/common.c b/arch/arm/mach-lpc32xx/common.c
index 304ea61a0716..50b91316d553 100644
--- a/arch/arm/mach-lpc32xx/common.c
+++ b/arch/arm/mach-lpc32xx/common.c
@@ -8,6 +8,7 @@
*/
#include <linux/init.h>
+#include <linux/of.h>
#include <linux/soc/nxp/lpc32xx-misc.h>
#include <asm/mach/map.h>
@@ -106,10 +107,19 @@ void __init lpc32xx_map_io(void)
iotable_init(lpc32xx_io_desc, ARRAY_SIZE(lpc32xx_io_desc));
}
+/* The arch_initcalls below poke LPC32xx-only registers; skip other SoCs. */
+bool __init lpc32xx_is_present(void)
+{
+ return of_machine_compatible_match(lpc32xx_dt_compat);
+}
+
static int __init lpc32xx_check_uid(void)
{
u32 uid[4];
+ if (!lpc32xx_is_present())
+ return 0;
+
lpc32xx_get_uid(uid);
printk(KERN_INFO "LPC32XX unique ID: %08x%08x%08x%08x\n",
diff --git a/arch/arm/mach-lpc32xx/common.h b/arch/arm/mach-lpc32xx/common.h
index 32f0ad217807..d00b6761796d 100644
--- a/arch/arm/mach-lpc32xx/common.h
+++ b/arch/arm/mach-lpc32xx/common.h
@@ -17,6 +17,8 @@
*/
extern void __init lpc32xx_map_io(void);
extern void __init lpc32xx_serial_init(void);
+extern bool __init lpc32xx_is_present(void);
+extern const char *const lpc32xx_dt_compat[];
/*
* Returns the LPC32xx unique 128-bit chip ID
diff --git a/arch/arm/mach-lpc32xx/phy3250.c b/arch/arm/mach-lpc32xx/phy3250.c
index 66701bf43248..b1ee31b9d2d2 100644
--- a/arch/arm/mach-lpc32xx/phy3250.c
+++ b/arch/arm/mach-lpc32xx/phy3250.c
@@ -76,7 +76,7 @@ static void __init lpc3250_machine_init(void)
of_platform_default_populate(NULL, lpc32xx_auxdata_lookup, NULL);
}
-static const char *const lpc32xx_dt_compat[] __initconst = {
+const char *const lpc32xx_dt_compat[] __initconst = {
"nxp,lpc3220",
"nxp,lpc3230",
"nxp,lpc3240",
diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c
index 2572bd89a5e8..2ad2b2d7cd72 100644
--- a/arch/arm/mach-lpc32xx/pm.c
+++ b/arch/arm/mach-lpc32xx/pm.c
@@ -122,6 +122,9 @@ static const struct platform_suspend_ops lpc32xx_pm_ops = {
#define EMC_CTRL_REG io_p2v(LPC32XX_EMC_BASE + EMC_DYN_MEM_CTRL_OFS)
static int __init lpc32xx_pm_init(void)
{
+ if (!lpc32xx_is_present())
+ return 0;
+
/*
* Setup SDRAM self-refresh clock to automatically disable o
* start of self-refresh. This only needs to be done once.
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ARM: lpc32xx: only run arch_initcalls on LPC32xx hardware
2026-07-12 20:56 [PATCH] ARM: lpc32xx: only run arch_initcalls on LPC32xx hardware Karl Mehltretter
@ 2026-07-12 21:04 ` Arnd Bergmann
0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2026-07-12 21:04 UTC (permalink / raw)
To: Karl Mehltretter, Vladimir Zapolskiy, Piotr Wojtaszczyk
Cc: linux-arm-kernel, linux-kernel
On Sun, Jul 12, 2026, at 22:56, Karl Mehltretter wrote:
> lpc32xx_check_uid() and lpc32xx_pm_init() are arch_initcalls that poke
> LPC32xx-only registers (the CLKPWR unique-ID and the EMC control
> register). Since the multiplatform conversion they also run on other
> ARCH_MULTI_V5 boards, where the access faults, e.g. on versatile:
>
> Unable to handle kernel paging request at virtual address f4004130
> PC is at lpc32xx_check_uid+0x2c/0x9c
>
> Bail out of both unless we are running on an LPC32xx SoC, reusing the
> machine's DT_MACHINE compatible list so the guard can't drift from it.
>
> Fixes: 75bf1bd7d2f9 ("ARM: lpc32xx: allow multiplatform build")
> Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Hi Karl,
This fix looks correct to me, but I think it would be better
to replace the arch_initcall() entries with a direct function
call from lpc3250_machine_init(), which also runs at the
arch_initcall level and is already guarded properly.
The calls should be entered in link order, which would
mean common.c, pm.c, phy3250.c.
Arnd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-12 21:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-12 20:56 [PATCH] ARM: lpc32xx: only run arch_initcalls on LPC32xx hardware Karl Mehltretter
2026-07-12 21:04 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox