xref: /linux/arch/mips/loongson64/boardinfo.c (revision cdd38c5f1ce4398ec58fec95904b75824daab7b5)
1*6c1bfbd9STiezhu Yang // SPDX-License-Identifier: GPL-2.0
2*6c1bfbd9STiezhu Yang #include <linux/kobject.h>
3*6c1bfbd9STiezhu Yang #include <boot_param.h>
4*6c1bfbd9STiezhu Yang 
boardinfo_show(struct kobject * kobj,struct kobj_attribute * attr,char * buf)5*6c1bfbd9STiezhu Yang static ssize_t boardinfo_show(struct kobject *kobj,
6*6c1bfbd9STiezhu Yang 			      struct kobj_attribute *attr, char *buf)
7*6c1bfbd9STiezhu Yang {
8*6c1bfbd9STiezhu Yang 	char board_manufacturer[64] = {0};
9*6c1bfbd9STiezhu Yang 	char *tmp_board_manufacturer = board_manufacturer;
10*6c1bfbd9STiezhu Yang 	char bios_vendor[64] = {0};
11*6c1bfbd9STiezhu Yang 	char *tmp_bios_vendor = bios_vendor;
12*6c1bfbd9STiezhu Yang 
13*6c1bfbd9STiezhu Yang 	strcpy(board_manufacturer, eboard->name);
14*6c1bfbd9STiezhu Yang 	strcpy(bios_vendor, einter->description);
15*6c1bfbd9STiezhu Yang 
16*6c1bfbd9STiezhu Yang 	return sprintf(buf,
17*6c1bfbd9STiezhu Yang 		       "Board Info\n"
18*6c1bfbd9STiezhu Yang 		       "Manufacturer\t\t: %s\n"
19*6c1bfbd9STiezhu Yang 		       "Board Name\t\t: %s\n"
20*6c1bfbd9STiezhu Yang 		       "Family\t\t\t: LOONGSON3\n\n"
21*6c1bfbd9STiezhu Yang 		       "BIOS Info\n"
22*6c1bfbd9STiezhu Yang 		       "Vendor\t\t\t: %s\n"
23*6c1bfbd9STiezhu Yang 		       "Version\t\t\t: %s\n"
24*6c1bfbd9STiezhu Yang 		       "ROM Size\t\t: %d KB\n"
25*6c1bfbd9STiezhu Yang 		       "Release Date\t\t: %s\n",
26*6c1bfbd9STiezhu Yang 		       strsep(&tmp_board_manufacturer, "-"),
27*6c1bfbd9STiezhu Yang 		       eboard->name,
28*6c1bfbd9STiezhu Yang 		       strsep(&tmp_bios_vendor, "-"),
29*6c1bfbd9STiezhu Yang 		       einter->description,
30*6c1bfbd9STiezhu Yang 		       einter->size,
31*6c1bfbd9STiezhu Yang 		       especial->special_name);
32*6c1bfbd9STiezhu Yang }
33*6c1bfbd9STiezhu Yang static struct kobj_attribute boardinfo_attr = __ATTR(boardinfo, 0444,
34*6c1bfbd9STiezhu Yang 						     boardinfo_show, NULL);
35*6c1bfbd9STiezhu Yang 
boardinfo_init(void)36*6c1bfbd9STiezhu Yang static int __init boardinfo_init(void)
37*6c1bfbd9STiezhu Yang {
38*6c1bfbd9STiezhu Yang 	struct kobject *lefi_kobj;
39*6c1bfbd9STiezhu Yang 
40*6c1bfbd9STiezhu Yang 	lefi_kobj = kobject_create_and_add("lefi", firmware_kobj);
41*6c1bfbd9STiezhu Yang 	if (!lefi_kobj) {
42*6c1bfbd9STiezhu Yang 		pr_err("lefi: Firmware registration failed.\n");
43*6c1bfbd9STiezhu Yang 		return -ENOMEM;
44*6c1bfbd9STiezhu Yang 	}
45*6c1bfbd9STiezhu Yang 
46*6c1bfbd9STiezhu Yang 	return sysfs_create_file(lefi_kobj, &boardinfo_attr.attr);
47*6c1bfbd9STiezhu Yang }
48*6c1bfbd9STiezhu Yang late_initcall(boardinfo_init);
49