From: Karl Mehltretter <kmehltretter@gmail.com>
To: Vladimir Zapolskiy <vz@mleia.com>,
Piotr Wojtaszczyk <piotr.wojtaszczyk@timesys.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Karl Mehltretter <kmehltretter@gmail.com>
Subject: [PATCH] ARM: lpc32xx: only run arch_initcalls on LPC32xx hardware
Date: Sun, 12 Jul 2026 22:56:17 +0200 [thread overview]
Message-ID: <20260712205617.44944-1-kmehltretter@gmail.com> (raw)
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)
next reply other threads:[~2026-07-12 20:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 20:56 Karl Mehltretter [this message]
2026-07-12 21:04 ` [PATCH] ARM: lpc32xx: only run arch_initcalls on LPC32xx hardware Arnd Bergmann
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=20260712205617.44944-1-kmehltretter@gmail.com \
--to=kmehltretter@gmail.com \
--cc=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=piotr.wojtaszczyk@timesys.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: 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