coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mainboard.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/device.h>
4 #include <console/console.h>
6 #include <ec/acpi/ec.h>
8 #include <string.h>
9 #include <smbios.h>
10 #include "ec.h"
11 
12 #include <acpi/acpi.h>
13 
14 static u8 mainboard_fill_ec_version(char *buf, u8 buf_len)
15 {
16  u8 i, c;
17  char str[16 + 1]; /* 16 ASCII chars + \0 */
18 
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;
25  }
26  str[i] = c;
27  }
28 
29  i = MIN(buf_len, i);
30  memcpy(buf, str, i);
31 
32  return i;
33 }
34 
36  struct device *dev, struct smbios_type11 *t)
37 {
38  char tpec[] = "IBM ThinkPad Embedded Controller -[ ]-";
39  u16 fwvh, fwvl;
40 
41  mainboard_fill_ec_version(tpec + 35, 17);
42  t->count = smbios_add_string(t->eos, tpec);
43 
44  /* Apparently byteswapped compared to H8 */
45  fwvh = ec_mm_read(0xe8);
46  fwvl = ec_mm_read(0xe9);
47 
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));
50 }
51 
52 static void mainboard_enable(struct device *dev)
53 {
54  dev->ops->get_smbios_strings = mainboard_smbios_strings,
55 
60  0);
61 
62  if (!acpi_is_wakeup_s3())
64 }
65 
68 };
struct chip_operations mainboard_ops
Definition: mainboard.c:19
static int acpi_is_wakeup_s3(void)
Definition: acpi.h:9
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
int smbios_add_string(u8 *start, const char *str)
Definition: smbios.c:40
#define MIN(a, b)
Definition: helpers.h:37
#define printk(level,...)
Definition: stdlib.h:16
void install_intel_vga_int15_handler(int active_lfp_, int pfit_, int display_, int panel_type_)
Definition: int15.c:101
@ GMA_INT15_BOOT_DISPLAY_DEFAULT
Definition: int15.h:6
@ GMA_INT15_ACTIVE_LFP_INT_LVDS
Definition: int15.h:25
@ GMA_INT15_PANEL_FIT_DEFAULT
Definition: int15.h:17
static void mainboard_smbios_strings(struct device *dev, struct smbios_type11 *t)
Definition: mainboard.c:35
static u8 mainboard_fill_ec_version(char *buf, u8 buf_len)
Definition: mainboard.c:14
static void mainboard_enable(struct device *dev)
Definition: mainboard.c:52
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
static uint8_t * buf
Definition: uart.c:7
void lenovo_s230u_ec_init(void)
Definition: ec.c:20
#define ec_mm_read(addr)
Definition: ec.h:9
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45
void(* enable_dev)(struct device *dev)
Definition: device.h:24
Definition: device.h:107
struct device_operations * ops
Definition: device.h:143
u8 eos[2]
Definition: smbios.h:815
#define c(value, pmcreg, dst_bits)
int snprintf(char *buf, size_t size, const char *fmt,...)
Note: This file is only for POSIX compatibility, and is meant to be chain-included via string....
Definition: vsprintf.c:35