All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Gerasimov <tossel@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/1] board: raspberrypi: add serial and revision to the device tree
Date: Wed, 20 Feb 2019 13:09:13 +0100	[thread overview]
Message-ID: <6186373fff2a94eddd91b28b41fb212c0d86caa1.1550664195.git.tossel@gmail.com> (raw)
In-Reply-To: <cover.1550664195.git.tossel@gmail.com>

Raspberry Pi bootloader adds this node to fdt, but if u-boot script
doesn't reuse the tree provided by it, this information is lost.

Revision and serial are displayed in /proc/cpuinfo after boot.

Suggested-By: Ricardo Salveti <rsalveti@rsalveti.net>
Reported-by: Karl Eaves <karleeaves@gmail.com>
Signed-off-by: Anton Gerasimov <tossel@gmail.com>
---
 board/raspberrypi/rpi/rpi.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 153a1fdcb7..f6a2cdfbfd 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -238,6 +238,8 @@ static uint32_t rev_scheme;
 static uint32_t rev_type;
 static const struct rpi_model *model;
 
+static uint64_t serial;
+
 #ifdef CONFIG_ARM64
 static struct mm_region bcm2837_mem_map[] = {
 	{
@@ -381,8 +383,8 @@ static void set_serial_number(void)
 		return;
 	}
 
-	snprintf(serial_string, sizeof(serial_string), "%016llx",
-		 msg->get_board_serial.body.resp.serial);
+	serial = msg->get_board_serial.body.resp.serial;
+	snprintf(serial_string, sizeof(serial_string), "%016llx", serial);
 	env_set("serial#", serial_string);
 }
 
@@ -475,6 +477,33 @@ void *board_fdt_blob_setup(void)
 	return (void *)fw_dtb_pointer;
 }
 
+static int ft_add_revision_info(void *blob) {
+	int off;
+	int ret;
+
+	off = fdt_subnode_offset(blob, 0, "system");
+
+	if (off < 0) {
+		off = fdt_add_subnode(blob, 0, "system");
+		if (off < 0)
+			return -1;
+	}
+
+	if (!fdt_getprop(blob, off, "linux,serial", NULL))  {
+		ret = fdt_setprop_u64(blob, off, "linux,serial", serial);
+		if (ret < 0)
+			return -1;
+	}
+
+	if (!fdt_getprop(blob, off, "linux,revision", NULL))  {
+		ret = fdt_setprop_u32(blob, off, "linux,revision", revision);
+		if (ret < 0)
+			return -1;
+	}
+
+	return 0;
+}
+
 int ft_board_setup(void *blob, bd_t *bd)
 {
 	/*
@@ -484,6 +513,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 	 */
 	lcd_dt_simplefb_add_node(blob);
 
+	ft_add_revision_info(blob);
+
 #ifdef CONFIG_EFI_LOADER
 	/* Reserve the spin table */
 	efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
-- 
2.19.1

  reply	other threads:[~2019-02-20 12:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20 12:09 [U-Boot] [PATCH v2 0/1] Pass board revision and serial number to the Anton Gerasimov
2019-02-20 12:09 ` Anton Gerasimov [this message]
2019-02-20 12:39   ` [U-Boot] [PATCH v2 1/1] board: raspberrypi: add serial and revision to the device tree Alexander Graf
2019-02-20 16:59   ` Stephen Warren
2019-02-20 17:04     ` Alexander Graf
2019-02-20 17:15       ` Stephen Warren
2019-02-20 18:26         ` Anton Gerasimov

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=6186373fff2a94eddd91b28b41fb212c0d86caa1.1550664195.git.tossel@gmail.com \
    --to=tossel@gmail.com \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.