mb/google/brya: Create rull variant
[coreboot2.git] / src / mainboard / google / trogdor / boardid.c
blob6db17069d3fc5430e2582c9699f19298614c3125
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <boardid.h>
4 #include <gpio.h>
5 #include <types.h>
7 uint32_t board_id(void)
9 static uint32_t id = UNDEFINED_STRAPPING_ID;
11 const gpio_t pins[] = {[2] = GPIO(31), [1] = GPIO(93), [0] = GPIO(33)};
13 if (id == UNDEFINED_STRAPPING_ID)
14 id = gpio_binary_first_base3_value(pins, ARRAY_SIZE(pins));
16 return id;
19 /* Some boards/revisions use one GPIO mapping and others use another. There's no real rhyme or
20 reason to it. Don't try to think about it too much... */
21 static bool use_old_pins(void)
23 return ((CONFIG(BOARD_GOOGLE_TROGDOR) && board_id() < 2) ||
24 CONFIG(BOARD_GOOGLE_LAZOR) ||
25 (CONFIG(BOARD_GOOGLE_POMPOM) && board_id() < 1));
28 uint32_t ram_code(void)
30 static uint32_t id = UNDEFINED_STRAPPING_ID;
32 const gpio_t old_pins[] = {[2] = GPIO(13), [1] = GPIO(19), [0] = GPIO(29)};
33 const gpio_t pins[] = {[2] = GPIO(5), [1] = GPIO(3), [0] = GPIO(1)};
35 if (id == UNDEFINED_STRAPPING_ID) {
36 if (use_old_pins())
37 id = gpio_base2_value(old_pins, ARRAY_SIZE(old_pins));
38 else
39 id = gpio_base2_value(pins, ARRAY_SIZE(pins));
42 return id;
45 static uint8_t panel_id(void)
47 const gpio_t pins[] = {[1] = GPIO(11), [0] = GPIO(4)};
49 return gpio_binary_first_base3_value(pins, ARRAY_SIZE(pins));
52 uint32_t sku_id(void)
54 static uint32_t id = UNDEFINED_STRAPPING_ID;
56 const gpio_t old_pins[] = {[2] = GPIO(20), [1] = GPIO(90), [0] = GPIO(105)};
57 const gpio_t pins[] = {[2] = GPIO(2), [1] = GPIO(90), [0] = GPIO(58)};
59 if (id == UNDEFINED_STRAPPING_ID) {
60 if (use_old_pins())
61 id = gpio_binary_first_base3_value(old_pins, ARRAY_SIZE(old_pins));
62 else
63 id = gpio_binary_first_base3_value(pins, ARRAY_SIZE(pins));
65 if (CONFIG(TROGDOR_HAS_MIPI_PANEL))
66 id = panel_id() << 8 | id;
69 return id;