summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-02-22 22:06:47 +0100
committerTom Rini <trini@konsulko.com>2016-02-24 18:44:12 -0500
commit757cd149b9c6928734fab0b831a7624168a0b71c (patch)
treed4f30da69e1c4f37a61ee435b1eb3a31f59aa6bc /board
parent6f6051fac360cf6ca88cfcfa3cb377778ef5742c (diff)
downloadu-boot-imx-757cd149b9c6928734fab0b831a7624168a0b71c.zip
u-boot-imx-757cd149b9c6928734fab0b831a7624168a0b71c.tar.gz
u-boot-imx-757cd149b9c6928734fab0b831a7624168a0b71c.tar.bz2
rpi: set board serial number in environment
Gets propagated into the device tree and then into /proc/cpuinfo where users often expect it. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Tested-by: Stephen Warren <swarren@wwwdotorg.org> Reviewed-by: Stephen Warren <swarren@wwwdotorg.org>
Diffstat (limited to 'board')
-rw-r--r--board/raspberrypi/rpi/rpi.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 7f4fe64..1d3a4e0 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -5,6 +5,7 @@
*/
#include <common.h>
+#include <inttypes.h>
#include <config.h>
#include <dm.h>
#include <fdt_support.h>
@@ -56,6 +57,12 @@ struct msg_get_board_rev {
u32 end_tag;
};
+struct msg_get_board_serial {
+ struct bcm2835_mbox_hdr hdr;
+ struct bcm2835_mbox_tag_get_board_serial get_board_serial;
+ u32 end_tag;
+};
+
struct msg_get_mac_address {
struct bcm2835_mbox_hdr hdr;
struct bcm2835_mbox_tag_get_mac_address get_mac_address;
@@ -281,6 +288,30 @@ static void set_board_info(void)
}
#endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */
+static void set_serial_number(void)
+{
+ ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_board_serial, msg, 1);
+ int ret;
+ char serial_string[17] = { 0 };
+
+ if (getenv("serial#"))
+ return;
+
+ BCM2835_MBOX_INIT_HDR(msg);
+ BCM2835_MBOX_INIT_TAG_NO_REQ(&msg->get_board_serial, GET_BOARD_SERIAL);
+
+ ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+ if (ret) {
+ printf("bcm2835: Could not query board serial\n");
+ /* Ignore error; not critical */
+ return;
+ }
+
+ snprintf(serial_string, sizeof(serial_string), "%016" PRIx64,
+ msg->get_board_serial.body.resp.serial);
+ setenv("serial#", serial_string);
+}
+
int misc_init_r(void)
{
set_fdtfile();
@@ -288,6 +319,8 @@ int misc_init_r(void)
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
set_board_info();
#endif
+ set_serial_number();
+
return 0;
}