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 
3 #include <boardid.h>
4 #include <ec/acpi/ec.h>
6 #include <stdint.h>
7 
8 #include "board_id.h"
9 
11 {
13 
15  id = BOARD_ID_UNKNOWN;
16 
17  return id;
18 }
19 
20 /*
21  * Get Board ID via EC I/O port write/read
22  * Board id is 5 bit, so mask other bits while returning board id.
23  */
24 int get_board_id(void)
25 {
26  MAYBE_STATIC_NONZERO int id = -1;
27 
28  if (id < 0) {
29  if (CONFIG(EC_GOOGLE_CHROMEEC)) {
31  } else {
32  uint8_t buffer[2];
33  uint8_t index;
34  if (send_ec_command(EC_FAB_ID_CMD) == 0) {
35  for (index = 0; index < sizeof(buffer); index++)
36  buffer[index] = recv_ec_data();
37  id = (buffer[0] << 8) | buffer[1];
38  }
39  }
40  }
41 
42  return (id & 0x1f);
43 }
int get_board_id(void)
Definition: board_id.c:20
#define EC_FAB_ID_CMD
Definition: board_id.h:7
#define BOARD_ID_INIT
Definition: boardid.h:11
#define BOARD_ID_UNKNOWN
Definition: boardid.h:10
@ CONFIG
Definition: dsi_common.h:201
int send_ec_command(u8 command)
Definition: ec.c:13
u8 recv_ec_data(void)
Definition: ec.c:65
int google_chromeec_get_board_version(uint32_t *version)
google_chromeec_get_board_version() - Get the board version
Definition: ec.c:915
static uint32_t get_board_id_via_ext_ec(void)
Definition: board_id.c:10
u8 buffer[C2P_BUFFER_MAXSIZE]
Definition: psp_smm.c:18
#define MAYBE_STATIC_NONZERO
Definition: stddef.h:38
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8