coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
gpio.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <baseboard/gpio.h>
4 #include <baseboard/variants.h>
5 #include <boardid.h>
6 #include <gpio.h>
7 #include <soc/gpio.h>
8 
9 /* This table is used by guybrush variant with board version < 2. */
10 static const struct soc_amd_gpio bid1_ramstage_gpio_table[] = {
11  /* EN_SPKR */
12  PAD_GPO(GPIO_69, HIGH),
13  /* SD_AUX_RESET_L */
14  PAD_GPO(GPIO_70, HIGH),
15  /* RAM_ID_CHAN_SEL */
17  /* EN_PP5000_PEN */
18  PAD_GPO(GPIO_5, HIGH),
19  /* GSC_SOC_INT_L */
20  PAD_INT(GPIO_3, PULL_NONE, EDGE_LOW, STATUS_DELIVERY),
21  /* Unused */
22  PAD_NC(GPIO_85),
23  /* EN_PWR_FP */
24  PAD_GPO(GPIO_32, LOW),
25 };
26 
27 /* This table is used by guybrush variant with board version >= 2. */
28 static const struct soc_amd_gpio bid2_ramstage_gpio_table[] = {
29  /* EN_PP5000_PEN */
30  PAD_GPO(GPIO_5, HIGH),
31  /* GSC_SOC_INT_L */
32  PAD_INT(GPIO_3, PULL_NONE, EDGE_LOW, STATUS_DELIVERY),
33  /* Unused */
34  PAD_NC(GPIO_85),
35  /* EN_PWR_FP */
36  PAD_GPO(GPIO_32, LOW),
37  /* EN_SPKR */
38  PAD_GPO(GPIO_31, LOW),
39  /* Unused TP27 */
40  PAD_NC(GPIO_70),
41 };
42 
43 static const struct soc_amd_gpio override_early_gpio_table[] = {
44  /* BID>=2: EN_SPKR to select RAM_ID input, BID < 2: Unused in later stages */
45  PAD_GPO(GPIO_31, LOW),
46  /* BID == 1: SD_AUX_RESET_L */
47  PAD_GPO(GPIO_70, LOW),
48 };
49 
50 /* This table is used by guybrush variant with board version < 2. */
51 static const struct soc_amd_gpio bid1_pcie_gpio_table[] = {
52  /* SD_AUX_RESET_L */
53  PAD_GPO(GPIO_70, HIGH),
54 };
55 
56 static const struct soc_amd_gpio tpm_gpio_table[] = {
57  /* I2C3_SCL */
58  PAD_NF(GPIO_19, I2C3_SCL, PULL_NONE),
59  /* I2C3_SDA */
60  PAD_NF(GPIO_20, I2C3_SDA, PULL_NONE),
61  /* GSC_SOC_INT_L */
62  PAD_INT(GPIO_3, PULL_NONE, EDGE_LOW, STATUS_DELIVERY),
63 };
64 
65 const struct soc_amd_gpio *variant_override_gpio_table(size_t *size)
66 {
67  uint32_t board_version = board_id();
68  *size = 0;
69 
70  if (board_version < 2) {
73  }
74 
77 }
78 
80 {
81  /*
82  * This code is run before the EC is available to check the board ID
83  * since this is needed to work on all versions of guybrush, just enable
84  * both GPIOs and reconfigure them on later stages.
85  */
88 }
89 
91 {
92  uint32_t board_version = board_id();
93  *size = 0;
94  if (board_version < 2) {
96  return bid1_pcie_gpio_table;
97  }
98 
99  return NULL;
100 }
101 
102 const struct soc_amd_gpio *variant_tpm_gpio_table(size_t *size)
103 {
104  *size = ARRAY_SIZE(tpm_gpio_table);
105  return tpm_gpio_table;
106 }
#define GPIO_32
Definition: gpio_ftns.h:15
#define ARRAY_SIZE(a)
Definition: helpers.h:12
uint32_t board_id(void)
board_id() - Get the board version
Definition: ec_boardid.c:6
#define PULL_NONE
Definition: buildOpts.c:72
const struct pad_config *__weak variant_override_gpio_table(size_t *num)
Definition: gpio.c:450
const struct soc_amd_gpio *__weak variant_early_override_gpio_table(size_t *size)
Definition: gpio.c:317
const __weak struct soc_amd_gpio * variant_tpm_gpio_table(size_t *size)
Definition: gpio.c:354
const struct soc_amd_gpio *__weak variant_pcie_override_gpio_table(size_t *size)
Definition: gpio.c:330
static const struct soc_amd_gpio tpm_gpio_table[]
Definition: gpio.c:56
static const struct soc_amd_gpio bid1_pcie_gpio_table[]
Definition: gpio.c:51
static const struct soc_amd_gpio bid1_ramstage_gpio_table[]
Definition: gpio.c:10
static const struct soc_amd_gpio bid2_ramstage_gpio_table[]
Definition: gpio.c:28
static const struct soc_amd_gpio override_early_gpio_table[]
Definition: gpio.c:43
#define GPIO_69
Definition: gpio.h:55
#define GPIO_5
Definition: gpio.h:26
#define GPIO_20
Definition: gpio.h:38
#define GPIO_19
Definition: gpio.h:37
#define GPIO_70
Definition: gpio.h:56
#define GPIO_31
Definition: gpio.h:47
#define GPIO_3
Definition: gpio.h:24
#define GPIO_85
Definition: gpio.h:61
#define GPIO_74
Definition: gpio.h:57
#define PAD_NC(pin)
Definition: gpio_defs.h:263
#define PAD_GPO(pin, direction)
Definition: gpio_defs.h:220
#define PAD_NF(pin, func, pull)
Definition: gpio_defs.h:208
#define PAD_INT(pin, pull, trigger, action)
Definition: gpio_defs.h:224
#define PAD_GPI(pin, pull)
Definition: gpio_defs.h:216
#define NULL
Definition: stddef.h:19
unsigned int uint32_t
Definition: stdint.h:14