coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
board_id.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #include "board_id.h"
3 #include <ec/acpi/ec.h>
4 #include <stdint.h>
5 #include <stddef.h>
6 
7 /*
8  * Get Board info via EC I/O port write/read
9  */
11 {
12  MAYBE_STATIC_NONZERO int ec_info = -1;
13  if (ec_info < 0) {
14  uint8_t buffer[2];
15  uint8_t index;
16  if (send_ec_command(EC_FAB_ID_CMD) == 0) {
17  for (index = 0; index < sizeof(buffer); index++)
18  buffer[index] = recv_ec_data();
19  ec_info = (buffer[1] << 8) | buffer[0];
20  }
21  }
22  return ec_info;
23 }
24 
25 /* Get spd index */
27 {
28  int ec_info = get_ec_boardinfo();
29  if (ec_info >= 0) {
30  *spd_index = ((uint16_t)ec_info >> 5) & 0x7;
31  return 0;
32  }
33  return -1;
34 }
35 
36 /* Get Board Id */
37 int get_board_id(void)
38 {
39  int ec_info = get_ec_boardinfo();
40  if (ec_info >= 0)
41  return ((uint16_t)ec_info >> 8) & 0xff;
42 
43  return -1;
44 }
int get_board_id(void)
Definition: board_id.c:20
#define EC_FAB_ID_CMD
Definition: board_id.h:7
int send_ec_command(u8 command)
Definition: ec.c:13
u8 recv_ec_data(void)
Definition: ec.c:65
int get_ec_boardinfo(void)
Definition: board_id.c:10
int get_spd_index(u8 *spd_index)
Definition: board_id.c:26
static const int spd_index[32]
Definition: memory.c:10
u8 buffer[C2P_BUFFER_MAXSIZE]
Definition: psp_smm.c:18
#define MAYBE_STATIC_NONZERO
Definition: stddef.h:38
unsigned short uint16_t
Definition: stdint.h:11
uint8_t u8
Definition: stdint.h:45
unsigned char uint8_t
Definition: stdint.h:8