From: Robin van der Gracht <robin.van.der.gracht@protonic.nl>
To: barebox@lists.infradead.org
Cc: Robin van der Gracht <robin.van.der.gracht@protonic.nl>,
David Jander <david@protonic.nl>
Subject: [PATCH v2 5/8] ARM: boards: protonic-rk356x: Move mecsbc code to model init function
Date: Tue, 10 Mar 2026 16:24:30 +0100 [thread overview]
Message-ID: <20260310152433.786340-6-robin.van.der.gracht@protonic.nl> (raw)
In-Reply-To: <20260310152433.786340-1-robin.van.der.gracht@protonic.nl>
Add the option to register a model specific late initcall function for
board specific initialization. This allows customization without
interfering with the board code for other Protonic rk356x models.
Signed-off-by: Robin van der Gracht <robin.van.der.gracht@protonic.nl>
---
arch/arm/boards/protonic-rk356x/board.c | 37 ++++++++++++++++++++++---
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boards/protonic-rk356x/board.c b/arch/arm/boards/protonic-rk356x/board.c
index 1aff5ddbc8..773bb37045 100644
--- a/arch/arm/boards/protonic-rk356x/board.c
+++ b/arch/arm/boards/protonic-rk356x/board.c
@@ -24,11 +24,14 @@ struct prt_rk356x_model {
const char *name;
const char *shortname;
const struct prt_rk356x_adc_chs adc_channels;
+ int (*init)(void);
};
struct prt_rk356x_priv {
int hw_id;
int hw_rev;
+ struct device *dev;
+ const struct prt_rk356x_model *model;
};
static struct prt_rk356x_priv prt_priv;
@@ -112,6 +115,33 @@ static int mecsbc_sd_of_fixup(struct device_node *root, void *context)
return 0;
}
+static int prt_rk356x_mecsbc_init(void)
+{
+ if (prt_priv.hw_id == 0 && prt_priv.hw_rev == 0)
+ of_register_fixup(mecsbc_sd_of_fixup, prt_priv.dev);
+
+ return 0;
+}
+
+static int prt_rk356x_devices_init(void)
+{
+ int ret;
+
+ if (!prt_priv.model)
+ return 0;
+
+ if (prt_priv.model->init) {
+ ret = prt_priv.model->init();
+ if (ret) {
+ pr_warn("Model init failed with %d\n", ret);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+late_initcall(prt_rk356x_devices_init);
+
static int prt_rk356x_of_fixup_hwrev(struct device *dev)
{
const char *compat;
@@ -124,10 +154,6 @@ static int prt_rk356x_of_fixup_hwrev(struct device *dev)
barebox_set_of_machine_compatible(buf);
free(buf);
-
- if (prt_priv.hw_id == 0 && prt_priv.hw_rev == 0)
- of_register_fixup(mecsbc_sd_of_fixup, dev);
-
return 0;
}
@@ -160,6 +186,8 @@ static int prt_rk356x_probe(struct device *dev)
prt_rk356x_process_adc(dev, &model->adc_channels);
prt_rk356x_of_fixup_hwrev(dev);
+ prt_priv.dev = dev;
+ prt_priv.model = model;
return 0;
}
@@ -167,6 +195,7 @@ static const struct prt_rk356x_model mecsbc = {
.name = "Protonic MECSBC board",
.shortname = "mecsbc",
.adc_channels = {0, 1, 3},
+ .init = prt_rk356x_mecsbc_init,
};
static const struct of_device_id prt_rk356x_of_match[] = {
--
2.43.0
next prev parent reply other threads:[~2026-03-10 15:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 15:24 [PATCH v2 0/8] ARM: boards: protonic-mecsbc: Generalization Robin van der Gracht
2026-03-10 15:24 ` [PATCH v2 1/8] ARM: boards: Rename protonic-mecsbc to protonic-rk356x Robin van der Gracht
2026-03-10 15:24 ` [PATCH v2 2/8] ARM: boards: protonic-rk356x: Remove VIN measurement Robin van der Gracht
2026-03-10 15:24 ` [PATCH v2 3/8] ARM: boards: protonic-rk356x: Use devicetree alias for saradc Robin van der Gracht
2026-03-10 15:24 ` [PATCH v2 4/8] ARM: boards: protonic-rk356x: Configure ADC and channels in model data Robin van der Gracht
2026-03-10 15:24 ` Robin van der Gracht [this message]
2026-03-10 15:24 ` [PATCH v2 6/8] ARM: boards: protonic-rk356x: Use rockchip_bbu_mmc_register Robin van der Gracht
2026-03-10 15:24 ` [PATCH v2 7/8] ARM: boards: protonic-rk356x: Move bbu setup to device late init Robin van der Gracht
2026-03-10 15:24 ` [PATCH v2 8/8] ARM: boards: protonic-rk356x: Read board serial and MAC address from eMMC Robin van der Gracht
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=20260310152433.786340-6-robin.van.der.gracht@protonic.nl \
--to=robin.van.der.gracht@protonic.nl \
--cc=barebox@lists.infradead.org \
--cc=david@protonic.nl \
/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