blob: 79ed15addcc1a3bed1b5898fe9458d2c5828656d [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>
T Michael Turneyb97e6f72021-03-18 09:16:44 -07007#include <gpio.h>
Sudheer Kumar Amrabadi1e811062022-07-19 16:32:27 +05308#include <soc/socinfo.h>
T Michael Turneyb97e6f72021-03-18 09:16:44 -07009
10uint32_t board_id(void)
11{
12 static uint32_t id = UNDEFINED_STRAPPING_ID;
Shelley Chen474da022022-11-29 11:14:34 -080013 if (id != UNDEFINED_STRAPPING_ID)
14 return id;
15
Subrata Banikeb14a972022-01-05 12:39:36 +053016 gpio_t pins[3] = { 0 };
Shelley Chenf58ce3b2022-01-05 13:02:59 -080017 if (CONFIG(BOARD_GOOGLE_HEROBRINE_REV0)) {
Ravi Kumar Bokka8b63dac2021-07-27 19:29:18 +053018 pins[2] = GPIO(75);
19 pins[1] = GPIO(74);
20 pins[0] = GPIO(73);
Shelley Chenf58ce3b2022-01-05 13:02:59 -080021 } else {
Ravi Kumar Bokka8b63dac2021-07-27 19:29:18 +053022 pins[2] = GPIO(50);
23 pins[1] = GPIO(49);
24 pins[0] = GPIO(48);
25 }
Ravi Kumar Bokka12184db2021-06-03 20:14:39 +053026
Shelley Chen474da022022-11-29 11:14:34 -080027 id = gpio_base3_value(pins, ARRAY_SIZE(pins));
T Michael Turneyb97e6f72021-03-18 09:16:44 -070028
29 return id;
30}
31
32uint32_t sku_id(void)
33{
Sudheer Kumar Amrabadi1e811062022-07-19 16:32:27 +053034 static uint32_t id = UNDEFINED_STRAPPING_ID;
Venkat Thogaru38ea9e32022-11-07 15:49:06 +053035
Shelley Chen474da022022-11-29 11:14:34 -080036 /*
37 * This means that we already retrieved the sku id from the EC once
38 * during this boot, so no need to do it again as we'll get the same
39 * value again.
40 */
41 if (id != UNDEFINED_STRAPPING_ID)
42 return id;
43
Venkat Thogaru38ea9e32022-11-07 15:49:06 +053044 /* Update modem status in 9th bit of sku id */
Sudheer Kumar Amrabadi1e811062022-07-19 16:32:27 +053045 uint32_t mask = 1 << 9;
Sudheer Kumar Amrabadi982bf992022-10-13 08:48:29 +053046
47 /* Update pro-part status in 10th bit of sku id */
48 uint32_t mask_pro = 1 << 10;
Sudheer Kumar Amrabadi1e811062022-07-19 16:32:27 +053049 id = google_chromeec_get_board_sku();
50 id = ((id & ~mask) | (socinfo_modem_supported() << 9));
Sudheer Kumar Amrabadi982bf992022-10-13 08:48:29 +053051 id = ((id & ~mask_pro) | (socinfo_pro_part() << 10));
Sudheer Kumar Amrabadi1e811062022-07-19 16:32:27 +053052 return id;
T Michael Turneyb97e6f72021-03-18 09:16:44 -070053}