mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] ARM: rpi: fix CM3 breakage after multi-image rework
@ 2022-05-02 14:29 Ahmad Fatoum
  2022-05-03  7:12 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-05-02 14:29 UTC (permalink / raw)
  To: barebox; +Cc: ore, Ahmad Fatoum

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


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

end of thread, other threads:[~2022-05-03  7:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 14:29 [PATCH master] ARM: rpi: fix CM3 breakage after multi-image rework Ahmad Fatoum
2022-05-03  7:12 ` Sascha Hauer

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