Debian Codegraph @

src/mainboard/intel/kblrvp/board_id.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #include "board_id.h"
3 #include <ec/acpi/ec.h>
4 #include <stdint.h>
5
6 /*
7 * Get Board info via EC I/O port write/read
8 */
9 int get_ec_boardinfo(void)
10 {
11 static int ec_info = -1;
12 if (ec_info < 0) {
13 uint8_t buffer[2];
14 uint8_t index;
15 if (send_ec_command(EC_FAB_ID_CMD) == 0) {
16 for (index = 0; index < sizeof(buffer); index++)
17 buffer[index] = recv_ec_data();
18 ec_info = (buffer[1] << 8) | buffer[0];
19 }
20 }
21 return ec_info;
22 }
23
24 /* Get spd index */
25 int get_spd_index(u8 *spd_index)
26 {
27 int ec_info = get_ec_boardinfo();
28 if (ec_info >= 0) {
29 *spd_index = ((uint16_t)ec_info >> 5) & 0x7;
30 return 0;
31 }
32 return -1;
33 }
34
35 /* Get Board Id */
36 int get_board_id(void)
37 {
38 int ec_info = get_ec_boardinfo();
39 if (ec_info >= 0)
40 return ((uint16_t)ec_info >> 8) & 0xff;
41
42 return -1;
43 }