1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Author: Huacai Chen <chenhuacai@loongson.cn> 4 * 5 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 6 */ 7 #include <linux/acpi.h> 8 #include <linux/efi.h> 9 #include <linux/export.h> 10 #include <linux/memblock.h> 11 #include <asm/early_ioremap.h> 12 #include <asm/bootinfo.h> 13 #include <asm/loongson.h> 14 15 u64 efi_system_table; 16 struct loongson_system_configuration loongson_sysconf; 17 EXPORT_SYMBOL(loongson_sysconf); 18 19 void __init init_environ(void) 20 { 21 int efi_boot = fw_arg0; 22 char *cmdline = early_memremap_ro(fw_arg1, COMMAND_LINE_SIZE); 23 24 if (efi_boot) 25 set_bit(EFI_BOOT, &efi.flags); 26 else 27 clear_bit(EFI_BOOT, &efi.flags); 28 29 strscpy(boot_command_line, cmdline, COMMAND_LINE_SIZE); 30 early_memunmap(cmdline, COMMAND_LINE_SIZE); 31 32 efi_system_table = fw_arg2; 33 } 34 35 static int __init init_cpu_fullname(void) 36 { 37 int cpu; 38 39 if (loongson_sysconf.cpuname && !strncmp(loongson_sysconf.cpuname, "Loongson", 8)) { 40 for (cpu = 0; cpu < NR_CPUS; cpu++) 41 __cpu_full_name[cpu] = loongson_sysconf.cpuname; 42 } 43 return 0; 44 } 45 arch_initcall(init_cpu_fullname); 46 47 static ssize_t boardinfo_show(struct kobject *kobj, 48 struct kobj_attribute *attr, char *buf) 49 { 50 return sprintf(buf, 51 "BIOS Information\n" 52 "Vendor\t\t\t: %s\n" 53 "Version\t\t\t: %s\n" 54 "ROM Size\t\t: %d KB\n" 55 "Release Date\t\t: %s\n\n" 56 "Board Information\n" 57 "Manufacturer\t\t: %s\n" 58 "Board Name\t\t: %s\n" 59 "Family\t\t\t: LOONGSON64\n\n", 60 b_info.bios_vendor, b_info.bios_version, 61 b_info.bios_size, b_info.bios_release_date, 62 b_info.board_vendor, b_info.board_name); 63 } 64 65 static struct kobj_attribute boardinfo_attr = __ATTR(boardinfo, 0444, 66 boardinfo_show, NULL); 67 68 static int __init boardinfo_init(void) 69 { 70 struct kobject *loongson_kobj; 71 72 loongson_kobj = kobject_create_and_add("loongson", firmware_kobj); 73 74 return sysfs_create_file(loongson_kobj, &boardinfo_attr.attr); 75 } 76 late_initcall(boardinfo_init); 77