} body;
};
+#define BCM2835_MBOX_TAG_GET_BOARD_SERIAL 0x00010004
+
+struct bcm2835_mbox_tag_get_board_serial {
+ struct bcm2835_mbox_tag_hdr tag_hdr;
+ union {
+ struct __packed {
+ u64 serial;
+ } resp;
+ } body;
+};
+
#define BCM2835_MBOX_TAG_GET_ARM_MEMORY 0x00010005
struct bcm2835_mbox_tag_get_arm_mem {
*/
#include <common.h>
+#include <inttypes.h>
#include <config.h>
#include <dm.h>
#include <fdt_support.h>
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;
}
#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();
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
set_board_info();
#endif
+ set_serial_number();
+
return 0;
}