1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #include <boardid.h> 4 #include <ec/google/chromeec/ec.h> 5 #include "board.h" 6 #include <commonlib/bsd/cb_err.h> 7 #include <gpio.h> 8 #include <soc/socinfo.h> 9 board_id(void)10uint32_t board_id(void) 11 { 12 static uint32_t id = UNDEFINED_STRAPPING_ID; 13 if (id != UNDEFINED_STRAPPING_ID) 14 return id; 15 16 gpio_t pins[3] = { 0 }; 17 if (CONFIG(BOARD_GOOGLE_HEROBRINE_REV0)) { 18 pins[2] = GPIO(75); 19 pins[1] = GPIO(74); 20 pins[0] = GPIO(73); 21 } else { 22 pins[2] = GPIO(50); 23 pins[1] = GPIO(49); 24 pins[0] = GPIO(48); 25 } 26 27 id = gpio_base3_value(pins, ARRAY_SIZE(pins)); 28 29 return id; 30 } 31 sku_id(void)32uint32_t sku_id(void) 33 { 34 static uint32_t id = UNDEFINED_STRAPPING_ID; 35 36 /* 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 44 /* Update modem status in 9th bit of sku id */ 45 uint32_t mask = 1 << 9; 46 47 /* Update pro-part status in 10th bit of sku id */ 48 uint32_t mask_pro = 1 << 10; 49 id = google_chromeec_get_board_sku(); 50 id = ((id & ~mask) | (socinfo_modem_supported() << 9)); 51 id = ((id & ~mask_pro) | (socinfo_pro_part() << 10)); 52 return id; 53 } 54