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
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
}
boardid.h
UNDEFINED_STRAPPING_ID
#define UNDEFINED_STRAPPING_ID
Definition:
boardid.h:8
ARRAY_SIZE
#define ARRAY_SIZE(a)
Definition:
helpers.h:12
GPIO
@ GPIO
Definition:
chip.h:84
CONFIG
@ CONFIG
Definition:
dsi_common.h:201
board_id
uint32_t board_id(void)
board_id() - Get the board version
Definition:
boardid.c:6
gpio_base2_value
uint32_t gpio_base2_value(const gpio_t gpio[], int num_gpio)
Definition:
gpio.c:30
gpio_binary_first_base3_value
static uint32_t gpio_binary_first_base3_value(const gpio_t gpio[], int num_gpio)
Definition:
gpio.h:93
sku_id
uint32_t sku_id(void)
Definition:
boardid.c:65
ram_code
uint32_t ram_code(void)
Definition:
boardid.c:78
use_old_pins
static bool use_old_pins(void)
Definition:
boardid.c:21
panel_id
static uint8_t panel_id(void)
Definition:
boardid.c:45
pins
static struct @1213 pins[]
uint32_t
unsigned int uint32_t
Definition:
stdint.h:14
uint8_t
unsigned char uint8_t
Definition:
stdint.h:8
gpio_t
Definition:
gpio_base.h:7
src
mainboard
google
trogdor
boardid.c
Generated by
1.9.1