Debian Codegraph @

src/mainboard/google/trogdor/boardid.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <boardid.h>
4 #include <gpio.h>
5 #include <types.h>
6
7 uint32_t board_id(void)
8 {
9 static uint32_t id = UNDEFINED_STRAPPING_ID;
10
11 const gpio_t pins[] = {[2] = GPIO(31), [1] = GPIO(93), [0] = GPIO(33)};
12
13 if (id == UNDEFINED_STRAPPING_ID)
14 id = gpio_binary_first_base3_value(pins, ARRAY_SIZE(pins));
15
16 return id;
17 }
18
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)
22 {
23 return ((CONFIG(BOARD_GOOGLE_TROGDOR) && board_id() < 2) ||
24 CONFIG(BOARD_GOOGLE_LAZOR) ||
25 (CONFIG(BOARD_GOOGLE_POMPOM) && board_id() < 1));
26 }
27
28 uint32_t ram_code(void)
29 {
30 static uint32_t id = UNDEFINED_STRAPPING_ID;
31
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)};
34
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));
40 }
41
42 return id;
43 }
44
45 static uint8_t panel_id(void)
46 {
47 const gpio_t pins[] = {[1] = GPIO(11), [0] = GPIO(4)};
48
49 return gpio_binary_first_base3_value(pins, ARRAY_SIZE(pins));
50 }
51
52 uint32_t sku_id(void)
53 {
54 static uint32_t id = UNDEFINED_STRAPPING_ID;
55
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)};
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));
64
65 if (CONFIG(TROGDOR_HAS_MIPI_PANEL))
66 id = panel_id() << 8 | id;
67 }
68
69 return id;
70 }