cpu/x86/smm/pci_resource_store: Store DEV/VEN ID
[coreboot2.git] / src / mainboard / lenovo / s230u / mainboard.c
blobb5e3b8786d5bc616101f490b591f9292e3428c6d
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/device.h>
4 #include <console/console.h>
5 #include <drivers/intel/gma/int15.h>
6 #include <ec/acpi/ec.h>
7 #include <southbridge/intel/common/gpio.h>
8 #include <string.h>
9 #include <smbios.h>
10 #include "ec.h"
12 #include <acpi/acpi.h>
14 static u8 mainboard_fill_ec_version(char *buf, u8 buf_len)
16 u8 i, c;
17 char str[16 + 1]; /* 16 ASCII chars + \0 */
19 /* Build ID */
20 for (i = 0; i < 8; i++) {
21 c = ec_mm_read(0xf0 + i);
22 if (c < 0x20 || c > 0x7f) {
23 i = snprintf(str, sizeof(str), "*INVALID");
24 break;
26 str[i] = c;
29 i = MIN(buf_len, i);
30 memcpy(buf, str, i);
32 return i;
35 static void mainboard_smbios_strings(
36 struct device *dev, struct smbios_type11 *t)
38 char tpec[] = "IBM ThinkPad Embedded Controller -[ ]-";
39 u16 fwvh, fwvl;
41 mainboard_fill_ec_version(tpec + 35, 17);
42 t->count = smbios_add_string(t->eos, tpec);
44 /* Apparently byteswapped compared to H8 */
45 fwvh = ec_mm_read(0xe8);
46 fwvl = ec_mm_read(0xe9);
48 printk(BIOS_INFO, "EC Firmware ID %.54s, Version %d.%d%d%c\n", tpec,
49 fwvh >> 4, fwvh & 0x0f, fwvl >> 4, 0x41 + (fwvl & 0xf));
52 static void mainboard_enable(struct device *dev)
54 dev->ops->get_smbios_strings = mainboard_smbios_strings;
56 install_intel_vga_int15_handler(
57 GMA_INT15_ACTIVE_LFP_INT_LVDS,
58 GMA_INT15_PANEL_FIT_DEFAULT,
59 GMA_INT15_BOOT_DISPLAY_DEFAULT,
60 0);
62 if (!acpi_is_wakeup_s3())
63 lenovo_s230u_ec_init();
66 struct chip_operations mainboard_ops = {
67 .enable_dev = mainboard_enable,