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 <bootstate.h>
6 #include <fw_config.h>
7 
8 /* Pad configuration in ramstage */
9 static const struct pad_config override_gpio_table[] = {
10  /* A10 : WWAN_EN */
11  PAD_CFG_GPO(GPP_A10, 1, PWROK),
12  /* C12 : AP_PEN_DET_ODL ==> NC */
13  PAD_NC(GPP_C12, UP_20K),
14  /* C18 : AP_I2C_EMR_SDA */
16  /* C19 : AP_I2C_EMR_SCL */
18  /* C22 : UART2_RTS_N ==> NC */
19  PAD_NC(GPP_C22, UP_20K),
20  /* D0 : WWAN_HOST_WAKE ==> WWAN_WDISABLE_L */
21  PAD_CFG_GPO(GPP_D0, 1, DEEP),
22  /* D12 : WCAM_RST_L ==> NC */
24  /* D14 : EN_PP1200_CAMERA ==> NC */
26  /* D15 : UCAM_RST_L ==> NC */
28  /* D19 : WWAN_WLAN_COEX1 ==> NC */
30  /* D20 : WWAN_WLAN_COEX2 ==> NC */
32  /* D21 : WWAN_WLAN_COEX3 ==> NC */
34  /* E0 : CLK_24M_UCAM ==> NC */
35  PAD_NC(GPP_E0, NONE),
36  /* E2 : CLK_24M_WCAM ==> NC */
37  PAD_NC(GPP_E2, NONE),
38  /* H1 : EN_PP3300_SD_U ==> NC */
39  PAD_NC(GPP_H1, NONE),
40  /* H6 : AP_I2C_CAM_SDA ==> NC */
41  PAD_NC(GPP_H6, NONE),
42  /* H7 : AP_I2C_CAM_SCL ==> NC */
43  PAD_NC(GPP_H7, NONE),
44  /* H16 : AP_SUB_IO_L ==> HP_RST_ODL */
45  PAD_CFG_GPO(GPP_H16, 1, PWROK),
46  /* H17 : WWAN_RST_L */
47  PAD_CFG_GPO(GPP_H17, 1, PLTRST),
48  /* G0 : SD_CMD ==> NC */
49  PAD_NC(GPP_G0, NONE),
50  /* G1 : SD_DATA0 ==> NC */
51  PAD_NC(GPP_G1, NONE),
52  /* G2 : SD_DATA1 ==> NC */
53  PAD_NC(GPP_G2, NONE),
54  /* G3 : SD_DATA2 ==> NC */
55  PAD_NC(GPP_G3, NONE),
56  /* G4 : SD_DATA3 ==> NC */
57  PAD_NC(GPP_G4, NONE),
58  /* G5 : SD_CD_ODL ==> NC */
59  PAD_NC(GPP_G5, UP_20K),
60  /* G6 : SD_CLK ==> NC */
61  PAD_NC(GPP_G6, NONE),
62  /* G7 : SD_SDIO_WP ==> NC */
63  PAD_NC(GPP_G7, NONE),
64 };
65 
66 static const struct pad_config lte_disable_pads[] = {
68  PAD_NC(GPP_D0, NONE),
70 };
71 
72 static const struct pad_config codec_da7219_pads[] = {
74 };
75 
76 static const struct pad_config codec_cs42l42_pads[] = {
78 };
79 
80 const struct pad_config *variant_override_gpio_table(size_t *num)
81 {
83  return override_gpio_table;
84 }
85 
86 static void fw_config_handle(void *unused)
87 {
88  if (!fw_config_probe(FW_CONFIG(LTE, LTE_PRESENT)))
90  if (fw_config_probe(FW_CONFIG(AUDIO_CODEC_SOURCE, AUDIO_CODEC_DA7219)))
92  if (fw_config_probe(FW_CONFIG(AUDIO_CODEC_SOURCE, AUDIO_CODEC_CS42l42)))
94 }
#define GPP_C12
#define GPP_H16
#define GPP_E0
#define GPP_D14
#define GPP_H17
#define GPP_D12
#define GPP_H6
#define GPP_C22
#define GPP_H7
#define GPP_H1
#define GPP_C18
#define GPP_D18
#define GPP_E2
#define GPP_A10
#define GPP_D0
#define GPP_C19
#define GPP_D19
#define GPP_D15
@ BS_DEV_ENABLE
Definition: bootstate.h:82
@ BS_ON_ENTRY
Definition: bootstate.h:95
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define GPP_G1
Definition: gpio_soc_defs.h:89
#define GPP_G7
Definition: gpio_soc_defs.h:95
#define GPP_G4
Definition: gpio_soc_defs.h:92
#define GPP_G2
Definition: gpio_soc_defs.h:90
#define GPP_D21
#define GPP_G6
Definition: gpio_soc_defs.h:94
#define GPP_G0
Definition: gpio_soc_defs.h:88
#define GPP_D20
#define GPP_G3
Definition: gpio_soc_defs.h:91
#define GPP_G5
Definition: gpio_soc_defs.h:93
#define FW_CONFIG(__field, __option)
Definition: fw_config.h:28
bool fw_config_probe(const struct fw_config *match)
Definition: fw_config.c:62
const struct pad_config *__weak variant_override_gpio_table(size_t *num)
Definition: gpio.c:450
BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fw_config_handle, NULL)
static const struct pad_config override_gpio_table[]
Definition: gpio.c:9
static const struct pad_config lte_disable_pads[]
Definition: gpio.c:66
static const struct pad_config codec_cs42l42_pads[]
Definition: gpio.c:76
static const struct pad_config codec_da7219_pads[]
Definition: gpio.c:72
static void fw_config_handle(void *unused)
Definition: gpio.c:86
void gpio_configure_pads(const struct soc_amd_gpio *gpio_list_ptr, size_t size)
program a particular set of GPIO
Definition: gpio.c:307
#define PAD_NC(pin)
Definition: gpio_defs.h:263
#define PAD_CFG_GPO(pad, val, rst)
Definition: gpio_defs.h:247
#define NULL
Definition: stddef.h:19
uint16_t unused
Definition: padconfig.h:13