Skip to content

Commit 7f08bd8

Browse files
committed
[CR] RISC-V:Populate BIOS vendor and serial number from device tree
1 parent bd170f4 commit 7f08bd8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

riscv64/corefreqk.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4203,12 +4203,38 @@ static struct notifier_block CoreFreqK_notifier_block = {
42034203
#ifdef CONFIG_OF
42044204
static void DeviceTree_Collect(void)
42054205
{
4206+
if (strlen(PUBLIC(RO(Proc))->SMB.BIOS.Vendor) == 0) {
4207+
const char *firmware;
4208+
struct device_node *chosen_node;
4209+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
4210+
chosen_node = of_chosen;
4211+
#else
4212+
chosen_node = of_find_node_by_path("/chosen");
4213+
#endif
4214+
if (chosen_node
4215+
&& of_property_read_string(chosen_node, "u-boot,version", &firmware) == 0)
4216+
{
4217+
StrCopy(PUBLIC(RO(Proc))->SMB.BIOS.Vendor, "U-Boot", MAX_UTS_LEN);
4218+
StrCopy(PUBLIC(RO(Proc))->SMB.BIOS.Version, firmware, MAX_UTS_LEN);
4219+
}
4220+
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
4221+
if (chosen_node) {
4222+
of_node_put(chosen_node);
4223+
}
4224+
#endif
4225+
}
42064226
if (strlen(PUBLIC(RO(Proc))->SMB.Board.Name) == 0) {
42074227
const char *modelName;
42084228
if (of_property_read_string(of_root, "model", &modelName) == 0) {
42094229
StrCopy(PUBLIC(RO(Proc))->SMB.Board.Name, modelName, MAX_UTS_LEN);
42104230
}
42114231
}
4232+
if (strlen(PUBLIC(RO(Proc))->SMB.Board.Serial) == 0) {
4233+
const char *serialNum;
4234+
if (of_property_read_string(of_root, "serial-number", &serialNum) == 0) {
4235+
StrCopy(PUBLIC(RO(Proc))->SMB.Board.Serial, serialNum, MAX_UTS_LEN);
4236+
}
4237+
}
42124238
if (strlen(PUBLIC(RO(Proc))->SMB.System.Vendor) == 0) {
42134239
const char *systemVendor;
42144240
if (of_property_read_string(of_root, "compatible", &systemVendor) == 0) {

0 commit comments

Comments
 (0)