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 <
console/console.h
>
6
7
/*
8
* Storm boards dedicate to the board ID three GPIOs in tertiary mode: 29, 30
9
* and 68. On proto0 GPIO68 is used and tied low, so it reads as 'zero' by
10
* gpio_base3_value(), whereas the other two pins are not connected
11
* and read as 'two'. This results in gpio_base3_value() returning
12
* 8 on proto0.
13
*
14
* Three tertitiary signals could represent 27 different values. To make
15
* calculated board ID value continuous and starting at zero, offset the
16
* calculated value by 19 (i.e. 27 - 8) and return modulo 27 of the offset
17
* number. This results in proto0 returning zero as the board ID, the future
18
* revisions will have the inputs configured to match the actual board
19
* revision.
20
*/
21
22
static
int
board_id_value
= -1;
23
24
static
uint8_t
get_board_id
(
void
)
25
{
26
uint8_t
bid;
27
gpio_t
hw_rev_gpios[] = {[2] = 68, [1] = 30, [0] = 29};
/* 29 is LSB */
28
int
offset
= 19;
29
30
bid =
gpio_base3_value
(hw_rev_gpios,
ARRAY_SIZE
(hw_rev_gpios));
31
bid = (bid +
offset
) % 27;
32
printk
(
BIOS_INFO
,
"Board ID %d\n"
, bid);
33
34
return
bid;
35
}
36
37
uint32_t
board_id
(
void
)
38
{
39
if
(
board_id_value
< 0)
40
board_id_value
=
get_board_id
();
41
42
return
board_id_value
;
43
}
boardid.h
ARRAY_SIZE
#define ARRAY_SIZE(a)
Definition:
helpers.h:12
printk
#define printk(level,...)
Definition:
stdlib.h:16
console.h
board_id
uint32_t board_id(void)
board_id() - Get the board version
Definition:
boardid.c:6
offset
static size_t offset
Definition:
flashconsole.c:16
gpio_base3_value
static uint32_t gpio_base3_value(const gpio_t gpio[], int num_gpio)
Definition:
gpio.h:63
BIOS_INFO
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition:
loglevel.h:113
get_board_id
static uint8_t get_board_id(void)
Definition:
boardid.c:24
board_id_value
static int board_id_value
Definition:
boardid.c:22
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
storm
boardid.c
Generated by
1.9.1