mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: ore@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] ARM: rpi: fix CM3 breakage after multi-image rework
Date: Mon,  2 May 2022 16:29:59 +0200	[thread overview]
Message-ID: <20220502142959.1325298-1-a.fatoum@pengutronix.de> (raw)

barebox used to apply quirks by asking VideoCore firmware. If this was
not possible, an error message is printed, but other initialization
happened as expected. With the move to board driver matched by DT, we
incur two breakages:

  - Compute Module 3/3+ used to be explicitly supported, but are absent
    in new compatible list
  - Unsupported variants used to initialize with only an error message,
    but now their revision ID must be known

Fix this by amending the compatible list with all non-Raspberry Pi 4
compatibles listed in the binding. We also make existence of a match
data optional and error out if it doesn't exist. This is so far unused,
but it conveys the intent for future users.

Fixes: c062cd5cf47d ("ARM: rpi: validate devicetree compatible instead of changing model name")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Only build-tested.
---
 arch/arm/boards/raspberry-pi/rpi-common.c | 32 ++++++++++++++++++++---
 arch/arm/mach-bcm283x/include/mach/mbox.h |  1 +
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 82da4d646482..41ef7d16773e 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -350,8 +350,10 @@ static const struct rpi_machine_data *rpi_get_dcfg(struct rpi_priv *priv)
 	const struct rpi_machine_data *dcfg;
 
 	dcfg = of_device_get_match_data(priv->dev);
-	if (!dcfg)
-		return ERR_PTR(-EINVAL);
+	if (!dcfg) {
+		dev_err(priv->dev, "Unknown board. Not applying fixups\n");
+		return NULL;
+	}
 
 	for (; dcfg->hw_id != U8_MAX; dcfg++) {
 		if (priv->hw_id & 0x800000) {
@@ -367,7 +369,7 @@ static const struct rpi_machine_data *rpi_get_dcfg(struct rpi_priv *priv)
 		return dcfg;
 	}
 
-	dev_err(priv->dev, "Failed to get dcfg for board_id: 0x%x.\n",
+	dev_err(priv->dev, "dcfg 0x%x for board_id doesn't match DT compatible\n",
 		priv->hw_id);
 	return ERR_PTR(-ENODEV);
 }
@@ -405,7 +407,7 @@ static int rpi_devices_probe(struct device_d *dev)
 	rpi_env_init();
 	rpi_vc_fdt();
 
-	if (dcfg->init)
+	if (dcfg && dcfg->init)
 		dcfg->init(priv);
 
 	reg = regulator_get_name("bcm2835_usb");
@@ -584,6 +586,24 @@ static const struct rpi_machine_data rpi_3_model_b_plus[] = {
 	},
 };
 
+static const struct rpi_machine_data rpi_compute_module_3[] = {
+	{
+		.hw_id = BCM2837_BOARD_REV_CM3,
+	}, {
+		.hw_id = BCM2837B0_BOARD_REV_CM3_PLUS,
+	}, {
+		.hw_id = U8_MAX
+	},
+};
+
+static const struct rpi_machine_data rpi_model_zero_2_w[] = {
+	{
+		.hw_id = BCM2837B0_BOARD_REV_ZERO_2,
+	}, {
+		.hw_id = U8_MAX
+	},
+};
+
 static const struct of_device_id rpi_of_match[] = {
 	/* BCM2835 based Boards */
 	{ .compatible = "raspberrypi,model-a", .data = rpi_model_a },
@@ -604,6 +624,10 @@ static const struct of_device_id rpi_of_match[] = {
 	{ .compatible = "raspberrypi,3-model-a-plus", .data = rpi_3_model_a_plus },
 	{ .compatible = "raspberrypi,3-model-b", .data = rpi_3_model_b },
 	{ .compatible = "raspberrypi,3-model-b-plus", .data = rpi_3_model_b_plus },
+	{ .compatible = "raspberrypi,model-zero-2-w", .data = rpi_model_zero_2_w },
+	{ .compatible = "raspberrypi,3-compute-module", .data = rpi_compute_module_3 },
+	{ .compatible = "raspberrypi,3-compute-module-lite", .data = rpi_compute_module_3 },
+
 	{ /* sentinel */ },
 };
 BAREBOX_DEEP_PROBE_ENABLE(rpi_of_match);
diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h
index f10f5bc14844..a9f06512bc23 100644
--- a/arch/arm/mach-bcm283x/include/mach/mbox.h
+++ b/arch/arm/mach-bcm283x/include/mach/mbox.h
@@ -171,6 +171,7 @@ struct bcm2835_mbox_tag_hdr {
 #define BCM2837B0_BOARD_REV_3B_PLUS   	0x0d
 #define BCM2837B0_BOARD_REV_3A_PLUS   	0x0e
 #define BCM2837B0_BOARD_REV_CM3_PLUS	0x10
+#define BCM2837B0_BOARD_REV_ZERO_2	0x12
 
 struct bcm2835_mbox_tag_get_board_rev {
 	struct bcm2835_mbox_tag_hdr tag_hdr;
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2022-05-02 14:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02 14:29 Ahmad Fatoum [this message]
2022-05-03  7:12 ` Sascha Hauer

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=20220502142959.1325298-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=ore@pengutronix.de \
    /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