1 /* SPDX-License-Identifier: GPL-2.0-only */
6 #include <commonlib/helpers.h>
8 #include <console/console.h>
9 #include <device/device.h>
10 #include <device/i2c_bus.h>
15 #define MAX_STRING_LENGTH UUID_STRLEN
17 static struct device
*eeprom
;
19 static const char *eeprom_read_string(const enum bx26_strings idx
)
21 static char str
[MAX_STRING_LENGTH
+ 1];
24 printk(BIOS_WARNING
, "DMI: Serial EEPROM not found\n");
29 const size_t offset
= bx26_locations
[idx
].offset
;
30 const size_t length
= MIN(bx26_locations
[idx
].length
, MAX_STRING_LENGTH
);
32 if (i2c_dev_read_at16(eeprom
, (u8
*)str
, length
, offset
) != length
) {
33 printk(BIOS_WARNING
, "DMI: Failed to read serial EEPROM\n");
37 /* Terminate at first non-printable character. */
38 for (i
= 0; i
< length
; ++i
) {
48 const char *smbios_system_manufacturer(void)
50 return eeprom_read_string(SYSTEM_MANUFACTURER
);
53 const char *smbios_system_product_name(void)
55 return eeprom_read_string(SYSTEM_PRODUCT_NAME
);
58 const char *smbios_system_serial_number(void)
60 return eeprom_read_string(SYSTEM_SERIAL_NUMBER
);
63 const char *smbios_system_version(void)
65 return eeprom_read_string(SYSTEM_VERSION
);
68 void smbios_system_set_uuid(u8
*const uuid
)
70 if (parse_uuid(uuid
, eeprom_read_string(SYSTEM_UUID
))) {
71 printk(BIOS_WARNING
, "DMI: Cannot parse UUID\n");
72 memset(uuid
, 0x00, UUID_LEN
);
76 const char *smbios_mainboard_serial_number(void)
78 return eeprom_read_string(BOARD_SERIAL_NUMBER
);
81 const char *smbios_mainboard_version(void)
83 return eeprom_read_string(BOARD_VERSION
);
86 static void enable_dev(struct device
*dev
)
88 if (dev
->path
.type
!= DEVICE_PATH_I2C
|| (dev
->path
.i2c
.device
& 0xf0) != 0x50)
93 struct chip_operations drivers_secunet_dmi_ops
= {
94 .name
= "secunet DMI",
95 .enable_dev
= enable_dev
,