From: Łukasz Stelmach Date: Tue, 10 Oct 2017 11:11:54 +0000 (+0200) Subject: rpi: Read the value of RSTS register X-Git-Tag: accepted/tizen/unified/20191107.062134~98 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2296b82447a500a5fae601267cacb494405d7188;p=platform%2Fkernel%2Fu-boot.git rpi: Read the value of RSTS register RSTS register allows passing information from OS too bootloader upon reboot. Change-Id: I2fa04fa0e63e5c81f78901c06ca8884f7e89f8e8 Signed-off-by: Łukasz Stelmach --- diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h index 0b6c254..63fe380 100644 --- a/arch/arm/mach-bcm283x/include/mach/mbox.h +++ b/arch/arm/mach-bcm283x/include/mach/mbox.h @@ -489,6 +489,20 @@ struct bcm2835_mbox_tag_set_palette { } body; }; +#define BCM2835_MBOX_TAG_GET_RSTS 0x00040011 + +struct bcm2835_mbox_tag_get_rsts { + struct bcm2835_mbox_tag_hdr tag_hdr; + union { + struct { + } req; + struct { + u32 rsts; + } resp; + } body; +}; + + /* * Pass a raw u32 message to the VC, and receive a raw u32 back. * diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index 9e0abdd..90a9cbf 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -61,6 +61,34 @@ struct msg_get_clock_rate { u32 end_tag; }; +struct msg_get_rsts { + struct bcm2835_mbox_hdr hdr; + struct bcm2835_mbox_tag_get_rsts get_rsts; + u32 end_tag; +}; + +/* Dump a message. */ +#ifdef BCM2835_MBOX_DUMP_MESSAGES +#define BCM2835_MBOX_DUMP_MSG(msg) { \ + u32 *p = msg; \ + int i; \ + printf("%s:%d", __func__, __LINE__); \ + if (msg->hdr.code == 0) \ + printf(" req"); \ + else if (msg->hdr.code == 0x80000000) \ + printf(" resp"); \ + else if (msg->hdr.code == 0x80000000) \ + printf(" err"); \ + else \ + printf(" WAT‽"); \ + for (i = 0; i < sizeof(*(msg)) / sizeof(*p); i++) \ + printf(" 0x%08X", p[i]); \ + printf("\n"); \ +} +#else +#define BCM2835_MBOX_DUMP_MSG(msg) +#endif + #ifdef CONFIG_ARM64 #define DTB_DIR "broadcom/" #else @@ -358,6 +386,33 @@ unsigned long board_get_usable_ram_top(unsigned long total_size) return fw_dtb_pointer & ~0xffff; } +static void get_rsts(void) +{ + ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_rsts, msg, 1); + int ret; + char rsts_string[11] = { 0 }; + + BCM2835_MBOX_INIT_HDR(msg); + BCM2835_MBOX_INIT_TAG(&msg->get_rsts, GET_RSTS); + + BCM2835_MBOX_DUMP_MSG(msg); + + ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); + if (ret) { + printf("bcm2835: Could not query RSTS value\n"); + /* Ignore the error, let's carry on. */ + return; + } + + BCM2835_MBOX_DUMP_MSG(msg); + + snprintf(rsts_string, sizeof(rsts_string), "0x%08X", + msg->get_rsts.body.resp.rsts); + env_set("reg_rsts", rsts_string); + + return; +} + static void set_usbethaddr(void) { ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1); @@ -432,6 +487,7 @@ int misc_init_r(void) set_fdt_addr(); set_fdtfile(); set_usbethaddr(); + get_rsts(); #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG set_board_info(); #endif