u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: "Ivan T. Ivanov" <iivanov@suse.de>
To: Matthias Brugger <mbrugger@suse.com>,
	Peter Robinson <pbrobinson@gmail.com>
Cc: Dmitry Malkin <dmitry@bedrocksystems.com>,
	Thomas Fitzsimmons <fitzsim@fitzsim.org>,
	Peng Fan <peng.fan@nxp.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Anatolij Gustschin <agust@denx.de>,
	wahrenst@gmx.net, florian.fainelli@broadcom.com,
	u-boot@lists.denx.de, "Ivan T. Ivanov" <iivanov@suse.de>
Subject: [PATCH v3 3/7] rpi5: Use devicetree to retrieve board revision
Date: Mon, 18 Dec 2023 23:03:37 +0200	[thread overview]
Message-ID: <20231218210341.30073-4-iivanov@suse.de> (raw)
In-Reply-To: <20231218210341.30073-1-iivanov@suse.de>

Firmware on RPi5 return error on board revision query
through firmware interface, but on the other hand it fills
"linux,revision" in "system" node, so use it to detect board
revision.

	system {
		linux,revision = <0xc04170>;
		linux,serial = <0x6cf44e80 0x3c533ede>;
	};

Signed-off-by: Ivan T. Ivanov <iivanov@suse.de>
---
 board/raspberrypi/rpi/rpi.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index cd823ad746..2851ebc985 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -171,6 +171,11 @@ static const struct rpi_model rpi_models_new_scheme[] = {
 		DTB_DIR "bcm2711-rpi-cm4.dtb",
 		true,
 	},
+	[0x17] = {
+		"5 Model B",
+		DTB_DIR "bcm2712-rpi-5-b.dtb",
+		true,
+	},
 };
 
 static const struct rpi_model rpi_models_old_scheme[] = {
@@ -429,15 +434,27 @@ static void get_board_revision(void)
 	int ret;
 	const struct rpi_model *models;
 	uint32_t models_count;
+	ofnode node;
 
 	BCM2835_MBOX_INIT_HDR(msg);
 	BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV);
 
 	ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
 	if (ret) {
-		printf("bcm2835: Could not query board revision\n");
 		/* Ignore error; not critical */
-		return;
+		node = ofnode_path("/system");
+		if (!ofnode_valid(node)) {
+			printf("bcm2835: Could not find /system node\n");
+			return;
+		}
+
+		ret = ofnode_read_u32(node, "linux,revision", &revision);
+		if (ret) {
+			printf("bcm2835: Could not find linux,revision\n");
+			return;
+		}
+	} else {
+		revision = msg->get_board_rev.body.resp.rev;
 	}
 
 	/*
@@ -451,7 +468,6 @@ static void get_board_revision(void)
 	 * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=98367&start=250
 	 * http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=20594
 	 */
-	revision = msg->get_board_rev.body.resp.rev;
 	if (revision & 0x800000) {
 		rev_scheme = 1;
 		rev_type = (revision >> 4) & 0xff;
-- 
2.35.3


  parent reply	other threads:[~2023-12-18 21:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-18 21:03 [PATCH v3 0/7] rpi5: initial support Ivan T. Ivanov
2023-12-18 21:03 ` [PATCH v3 1/7] rpi5: add initial memory map for bcm2712 Ivan T. Ivanov
2023-12-18 22:25   ` Stefan Wahren
2023-12-19  8:40     ` Ivan T. Ivanov
2023-12-20  4:45   ` Simon Glass
2023-12-20  8:12     ` Ivan T. Ivanov
2023-12-20 12:08   ` Ivan T . Ivanov
2023-12-18 21:03 ` [PATCH v3 2/7] rpi5: Use devicetree as alternative way to read IO base addresses Ivan T. Ivanov
2023-12-22 11:08   ` Matthias Brugger
2023-12-18 21:03 ` Ivan T. Ivanov [this message]
2023-12-22 11:28   ` [PATCH v3 3/7] rpi5: Use devicetree to retrieve board revision Matthias Brugger
2023-12-18 21:03 ` [PATCH v3 4/7] bcm2835: brcm, bcm2708-fb device is using r5g6b5 format Ivan T. Ivanov
2023-12-18 22:32   ` [PATCH v3 4/7] bcm2835: brcm,bcm2708-fb " Stefan Wahren
2023-12-19  8:51     ` Ivan T. Ivanov
2023-12-19 10:35       ` Stefan Wahren
2023-12-20  8:51       ` Matthias Brugger
2023-12-21 13:51         ` Ivan T. Ivanov
2023-12-18 21:03 ` [PATCH v3 5/7] mmc: bcmstb: Add support for bcm2712 SD controller Ivan T. Ivanov
2023-12-21 15:13   ` Florian Fainelli
2023-12-21 15:39     ` Stefan Wahren
2023-12-22  8:22       ` Ivan T. Ivanov
2023-12-18 21:03 ` [PATCH v3 6/7] configs: rpi_arm64: enable SDHCI BCMSTB driver Ivan T. Ivanov
2023-12-18 21:03 ` [PATCH v3 7/7] pci: pcie-brcmstb: Add bcm2712 PCIe controller support Ivan T. Ivanov
2023-12-22 11:46   ` Matthias Brugger
2023-12-21 13:42 ` [PATCH v3 0/7] rpi5: initial support Stefan Agner
2023-12-21 13:51   ` Matthias Brugger
2023-12-22 12:19 ` Marc Zyngier
2023-12-22 12:33   ` Ivan T. Ivanov
2023-12-22 12:44     ` Marc Zyngier

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=20231218210341.30073-4-iivanov@suse.de \
    --to=iivanov@suse.de \
    --cc=agust@denx.de \
    --cc=dmitry@bedrocksystems.com \
    --cc=fitzsim@fitzsim.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=jh80.chung@samsung.com \
    --cc=mbrugger@suse.com \
    --cc=pbrobinson@gmail.com \
    --cc=peng.fan@nxp.com \
    --cc=u-boot@lists.denx.de \
    --cc=wahrenst@gmx.net \
    /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;
as well as URLs for NNTP newsgroup(s).