T Michael Turney | b97e6f7 | 2021-03-18 09:16:44 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <boardid.h> |
Philip Chen | 1158f71 | 2021-07-15 15:31:51 -0700 | [diff] [blame] | 4 | #include <ec/google/chromeec/ec.h> |
Ravi Kumar Bokka | 12184db | 2021-06-03 20:14:39 +0530 | [diff] [blame] | 5 | #include "board.h" |
| 6 | #include <commonlib/bsd/cb_err.h> |
| 7 | #include <console/console.h> |
T Michael Turney | b97e6f7 | 2021-03-18 09:16:44 -0700 | [diff] [blame] | 8 | #include <gpio.h> |
Sudheer Kumar Amrabadi | 1e81106 | 2022-07-19 16:32:27 +0530 | [diff] [blame] | 9 | #include <soc/socinfo.h> |
T Michael Turney | b97e6f7 | 2021-03-18 09:16:44 -0700 | [diff] [blame] | 10 | |
| 11 | uint32_t board_id(void) |
| 12 | { |
| 13 | static uint32_t id = UNDEFINED_STRAPPING_ID; |
Shelley Chen | 474da02 | 2022-11-29 11:14:34 -0800 | [diff] [blame^] | 14 | if (id != UNDEFINED_STRAPPING_ID) |
| 15 | return id; |
| 16 | |
Subrata Banik | eb14a97 | 2022-01-05 12:39:36 +0530 | [diff] [blame] | 17 | gpio_t pins[3] = { 0 }; |
Shelley Chen | f58ce3b | 2022-01-05 13:02:59 -0800 | [diff] [blame] | 18 | if (CONFIG(BOARD_GOOGLE_HEROBRINE_REV0)) { |
Ravi Kumar Bokka | 8b63dac | 2021-07-27 19:29:18 +0530 | [diff] [blame] | 19 | pins[2] = GPIO(75); |
| 20 | pins[1] = GPIO(74); |
| 21 | pins[0] = GPIO(73); |
Shelley Chen | f58ce3b | 2022-01-05 13:02:59 -0800 | [diff] [blame] | 22 | } else { |
Ravi Kumar Bokka | 8b63dac | 2021-07-27 19:29:18 +0530 | [diff] [blame] | 23 | pins[2] = GPIO(50); |
| 24 | pins[1] = GPIO(49); |
| 25 | pins[0] = GPIO(48); |
| 26 | } |
Ravi Kumar Bokka | 12184db | 2021-06-03 20:14:39 +0530 | [diff] [blame] | 27 | |
Shelley Chen | 474da02 | 2022-11-29 11:14:34 -0800 | [diff] [blame^] | 28 | id = gpio_base3_value(pins, ARRAY_SIZE(pins)); |
T Michael Turney | b97e6f7 | 2021-03-18 09:16:44 -0700 | [diff] [blame] | 29 | |
| 30 | return id; |
| 31 | } |
| 32 | |
| 33 | uint32_t sku_id(void) |
| 34 | { |
Sudheer Kumar Amrabadi | 1e81106 | 2022-07-19 16:32:27 +0530 | [diff] [blame] | 35 | static uint32_t id = UNDEFINED_STRAPPING_ID; |
Venkat Thogaru | 38ea9e3 | 2022-11-07 15:49:06 +0530 | [diff] [blame] | 36 | |
Shelley Chen | 474da02 | 2022-11-29 11:14:34 -0800 | [diff] [blame^] | 37 | /* |
| 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 Thogaru | 38ea9e3 | 2022-11-07 15:49:06 +0530 | [diff] [blame] | 45 | /* Update modem status in 9th bit of sku id */ |
Sudheer Kumar Amrabadi | 1e81106 | 2022-07-19 16:32:27 +0530 | [diff] [blame] | 46 | 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 Turney | b97e6f7 | 2021-03-18 09:16:44 -0700 | [diff] [blame] | 50 | } |