blob: 1f0c88fcb868eadb8146405563a89d07db5e0b16 [file] [log] [blame]
T Michael Turneyb97e6f72021-03-18 09:16:44 -07001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <boardid.h>
Philip Chen1158f712021-07-15 15:31:51 -07004#include <ec/google/chromeec/ec.h>
Ravi Kumar Bokka12184db2021-06-03 20:14:39 +05305#include "board.h"
6#include <commonlib/bsd/cb_err.h>
7#include <console/console.h>
T Michael Turneyb97e6f72021-03-18 09:16:44 -07008#include <gpio.h>
Sudheer Kumar Amrabadi1e811062022-07-19 16:32:27 +05309#include <soc/socinfo.h>
T Michael Turneyb97e6f72021-03-18 09:16:44 -070010
11uint32_t board_id(void)
12{
13 static uint32_t id = UNDEFINED_STRAPPING_ID;
Shelley Chen474da022022-11-29 11:14:34 -080014 if (id != UNDEFINED_STRAPPING_ID)
15 return id;
16
Subrata Banikeb14a972022-01-05 12:39:36 +053017 gpio_t pins[3] = { 0 };
Shelley Chenf58ce3b2022-01-05 13:02:59 -080018 if (CONFIG(BOARD_GOOGLE_HEROBRINE_REV0)) {
Ravi Kumar Bokka8b63dac2021-07-27 19:29:18 +053019 pins[2] = GPIO(75);
20 pins[1] = GPIO(74);
21 pins[0] = GPIO(73);
Shelley Chenf58ce3b2022-01-05 13:02:59 -080022 } else {
Ravi Kumar Bokka8b63dac2021-07-27 19:29:18 +053023 pins[2] = GPIO(50);
24 pins[1] = GPIO(49);
25 pins[0] = GPIO(48);
26 }
Ravi Kumar Bokka12184db2021-06-03 20:14:39 +053027
Shelley Chen474da022022-11-29 11:14:34 -080028 id = gpio_base3_value(pins, ARRAY_SIZE(pins));
T Michael Turneyb97e6f72021-03-18 09:16:44 -070029
30 return id;
31}
32
33uint32_t sku_id(void)
34{
Sudheer Kumar Amrabadi1e811062022-07-19 16:32:27 +053035 static uint32_t id = UNDEFINED_STRAPPING_ID;
Venkat Thogaru38ea9e32022-11-07 15:49:06 +053036
Shelley Chen474da022022-11-29 11:14:34 -080037 /*
38 * This means that we already retrieved the sku id from the EC once
39 * during this boot, so no need to do it again as we'll get the same
40 * value again.
41 */
42 if (id != UNDEFINED_STRAPPING_ID)
43 return id;
44
Venkat Thogaru38ea9e32022-11-07 15:49:06 +053045 /* Update modem status in 9th bit of sku id */
Sudheer Kumar Amrabadi1e811062022-07-19 16:32:27 +053046 uint32_t mask = 1 << 9;
47 id = google_chromeec_get_board_sku();
48 id = ((id & ~mask) | (socinfo_modem_supported() << 9));
49 return id;
T Michael Turneyb97e6f72021-03-18 09:16:44 -070050}