coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
boardid.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <boardid.h>
4 #include <gpio.h>
5 #include <types.h>
6 
8 {
10 
11  const gpio_t pins[] = {[2] = GPIO(31), [1] = GPIO(93), [0] = GPIO(33)};
12 
13  if (id == UNDEFINED_STRAPPING_ID)
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 
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
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 
50 }
51 
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
64 
65  if (CONFIG(TROGDOR_HAS_MIPI_PANEL))
66  id = panel_id() << 8 | id;
67  }
68 
69  return id;
70 }
#define UNDEFINED_STRAPPING_ID
Definition: boardid.h:8
#define ARRAY_SIZE(a)
Definition: helpers.h:12
@ GPIO
Definition: chip.h:84
@ CONFIG
Definition: dsi_common.h:201
uint32_t board_id(void)
board_id() - Get the board version
Definition: boardid.c:6
uint32_t gpio_base2_value(const gpio_t gpio[], int num_gpio)
Definition: gpio.c:30
static uint32_t gpio_binary_first_base3_value(const gpio_t gpio[], int num_gpio)
Definition: gpio.h:93
uint32_t sku_id(void)
Definition: boardid.c:65
uint32_t ram_code(void)
Definition: boardid.c:78
static bool use_old_pins(void)
Definition: boardid.c:21
static uint8_t panel_id(void)
Definition: boardid.c:45
static struct @1213 pins[]
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8