diff --git a/configs/pcengines.apu2.20160304.config b/configs/pcengines.apu2.4.0.1.config similarity index 99% rename from configs/pcengines.apu2.20160304.config rename to configs/pcengines.apu2.4.0.1.config index 853b7127697..531bd7a1d5b 100644 --- a/configs/pcengines.apu2.20160304.config +++ b/configs/pcengines.apu2.4.0.1.config @@ -7,7 +7,7 @@ # General setup # # CONFIG_EXPERT is not set -CONFIG_LOCALVERSION="" +CONFIG_LOCALVERSION="4.0.1" CONFIG_CBFS_PREFIX="fallback" CONFIG_COMPILER_GCC=y # CONFIG_COMPILER_LLVM_CLANG is not set @@ -375,7 +375,7 @@ CONFIG_GENERATE_SMBIOS_TABLES=y CONFIG_MAINBOARD_SERIAL_NUMBER="123456789" CONFIG_MAINBOARD_VERSION="1.0" CONFIG_MAINBOARD_SMBIOS_MANUFACTURER="PC Engines" -CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME="apu2" +CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME="APU2" # # Payload diff --git a/src/arch/x86/boot/smbios.c b/src/arch/x86/boot/smbios.c index f2f998d7bc3..d6368e7cdd3 100644 --- a/src/arch/x86/boot/smbios.c +++ b/src/arch/x86/boot/smbios.c @@ -203,6 +203,11 @@ void __attribute__((weak)) smbios_mainboard_set_uuid(u8 *uuid) /* leave all zero */ } +const char *__attribute__((weak)) smbios_mainboard_sku(void) +{ + return ""; +} + static int smbios_write_type1(unsigned long *current, int handle) { struct smbios_type1 *t = (struct smbios_type1 *)*current; @@ -215,6 +220,7 @@ static int smbios_write_type1(unsigned long *current, int handle) t->manufacturer = smbios_add_string(t->eos, smbios_mainboard_manufacturer()); t->product_name = smbios_add_string(t->eos, smbios_mainboard_product_name()); t->serial_number = smbios_add_string(t->eos, smbios_mainboard_serial_number()); + t->sku = smbios_add_string(t->eos, smbios_mainboard_sku()); t->version = smbios_add_string(t->eos, smbios_mainboard_version()); smbios_mainboard_set_uuid(t->uuid); len = t->length + smbios_string_table_len(t->eos); diff --git a/src/include/smbios.h b/src/include/smbios.h index 90609067b36..032041d3514 100644 --- a/src/include/smbios.h +++ b/src/include/smbios.h @@ -19,6 +19,7 @@ const char *smbios_mainboard_serial_number(void); const char *smbios_mainboard_version(void); void smbios_mainboard_set_uuid(u8 *uuid); const char *smbios_mainboard_bios_version(void); +const char *smbios_mainboard_sku(void); u8 smbios_mainboard_enclosure_type(void); #define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7) diff --git a/src/mainboard/pcengines/apu2/mainboard.c b/src/mainboard/pcengines/apu2/mainboard.c index 3d89aff6190..a84bd2973de 100644 --- a/src/mainboard/pcengines/apu2/mainboard.c +++ b/src/mainboard/pcengines/apu2/mainboard.c @@ -45,6 +45,10 @@ #endif //CONFIG_USE_CBMEM_FILE_OVERRIDE #include #include +#include +#include +#include +#include static bool check_console(void); @@ -284,4 +288,52 @@ struct chip_operations mainboard_ops = { .final = mainboard_final, }; +const char *smbios_mainboard_serial_number(void) +{ + static char serial[10]; + msr_t msr; + u32 mac_addr = 0; + device_t nic_dev; + + // Allows the IO configuration space access method, IOCF8 and IOCFC, to be + // used to generate extended configuration cycles + msr = rdmsr(NB_CFG_MSR); + msr.hi |= (ENABLE_CF8_EXT_CFG); + wrmsr(NB_CFG_MSR, msr); + + nic_dev = dev_find_slot(1, PCI_DEVFN(0, 0)); + + if ((serial[0] != 0) || !nic_dev) + return serial; + + // Read 4 bytes starting from 0x144 offset + mac_addr = pci_read_config32(nic_dev, 0x144); + // MSB here is always 0xff + // Discard it so only bottom 3b of mac address are left + mac_addr &= 0x00ffffff; + + // Set bit EnableCf8ExtCfg back to 0 + msr.hi &= ~(ENABLE_CF8_EXT_CFG); + wrmsr(NB_CFG_MSR, msr); + // Calculate serial value + mac_addr /= 4; + mac_addr -= 64; + + snprintf(serial, sizeof(serial), "%d", mac_addr); + + return serial; +} + +const char *smbios_mainboard_sku(void) +{ + static char sku[5]; + if (sku[0] != 0) + return sku; + + if (!ReadFchGpio(APU2_SPD_STRAP0_GPIO)) + snprintf(sku, sizeof(sku), "2 GB"); + else + snprintf(sku, sizeof(sku), "4 GB"); + return sku; +}