c0d3eb0d677d3f7e154d708ebe6f1ada9c869bc8
[openwrt/staging/wigyori.git] /
1 From 650cd61348897bbf19addafe37b8559aa4e75710 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Thu, 10 Jan 2019 17:58:06 +0000
4 Subject: [PATCH] firmware: raspberrypi: Report the fw variant during
5 probe
6
7 The driver already reported the firmware build date during probe.
8 The mailbox calls have been extended to also report the variant
9 1 = standard start.elf
10 2 = start_x.elf (includes camera stack)
11 3 = start_db.elf (includes assert logging)
12 4 = start_cd.elf (cutdown version for smallest memory footprint).
13 Log the variant during probe.
14
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
16
17 firmware: raspberrypi: Report the fw git hash during probe
18
19 The firmware can now report the git hash from which it was built
20 via the mailbox, so report it during probe.
21
22 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
23 ---
24 drivers/firmware/raspberrypi.c | 49 ++++++++++++++++++----
25 include/soc/bcm2835/raspberrypi-firmware.h | 2 +
26 2 files changed, 44 insertions(+), 7 deletions(-)
27
28 --- a/drivers/firmware/raspberrypi.c
29 +++ b/drivers/firmware/raspberrypi.c
30 @@ -229,21 +229,55 @@ static const struct attribute_group rpi_
31 static void
32 rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
33 {
34 + static const char * const variant_strs[] = {
35 + "unknown",
36 + "start",
37 + "start_x",
38 + "start_db",
39 + "start_cd",
40 + };
41 + const char *variant_str = "cmd unsupported";
42 u32 packet;
43 + u32 variant;
44 + struct tm tm;
45 int ret = rpi_firmware_property(fw,
46 RPI_FIRMWARE_GET_FIRMWARE_REVISION,
47 &packet, sizeof(packet));
48
49 - if (ret == 0) {
50 - struct tm tm;
51 + if (ret)
52 + return;
53
54 - time64_to_tm(packet, 0, &tm);
55 + ret = rpi_firmware_property(fw, RPI_FIRMWARE_GET_FIRMWARE_VARIANT,
56 + &variant, sizeof(variant));
57
58 - dev_info(fw->cl.dev,
59 - "Attached to firmware from %04ld-%02d-%02d %02d:%02d\n",
60 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
61 - tm.tm_hour, tm.tm_min);
62 + if (!ret) {
63 + if (variant >= ARRAY_SIZE(variant_strs))
64 + variant = 0;
65 + variant_str = variant_strs[variant];
66 }
67 +
68 + time64_to_tm(packet, 0, &tm);
69 +
70 + dev_info(fw->cl.dev,
71 + "Attached to firmware from %04ld-%02d-%02d %02d:%02d, variant %s\n",
72 + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
73 + tm.tm_min, variant_str);
74 +}
75 +
76 +static void
77 +rpi_firmware_print_firmware_hash(struct rpi_firmware *fw)
78 +{
79 + u32 hash[5];
80 + int ret = rpi_firmware_property(fw,
81 + RPI_FIRMWARE_GET_FIRMWARE_HASH,
82 + hash, sizeof(hash));
83 +
84 + if (ret)
85 + return;
86 +
87 + dev_info(fw->cl.dev,
88 + "Firmware hash is %08x%08x%08x%08x%08x\n",
89 + hash[0], hash[1], hash[2], hash[3], hash[4]);
90 }
91
92 static void
93 @@ -298,6 +332,7 @@ static int rpi_firmware_probe(struct pla
94 g_pdev = pdev;
95
96 rpi_firmware_print_firmware_revision(fw);
97 + rpi_firmware_print_firmware_hash(fw);
98 rpi_register_hwmon_driver(dev, fw);
99 rpi_register_clk_driver(dev);
100
101 --- a/include/soc/bcm2835/raspberrypi-firmware.h
102 +++ b/include/soc/bcm2835/raspberrypi-firmware.h
103 @@ -38,6 +38,8 @@ struct rpi_firmware_property_tag_header
104 enum rpi_firmware_property_tag {
105 RPI_FIRMWARE_PROPERTY_END = 0,
106 RPI_FIRMWARE_GET_FIRMWARE_REVISION = 0x00000001,
107 + RPI_FIRMWARE_GET_FIRMWARE_VARIANT = 0x00000002,
108 + RPI_FIRMWARE_GET_FIRMWARE_HASH = 0x00000003,
109
110 RPI_FIRMWARE_SET_CURSOR_INFO = 0x00008010,
111 RPI_FIRMWARE_SET_CURSOR_STATE = 0x00008011,