coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
fw_config.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <bootstate.h>
4 #include <console/console.h>
5 #include <fw_config.h>
6 #include <gpio.h>
7 
8 static const struct pad_config dmic_enable_pads[] = {
9  PAD_CFG_NF(GPP_S4, NONE, DEEP, NF2), /* DMIC_CLK1 */
10  PAD_CFG_NF(GPP_S5, NONE, DEEP, NF2), /* DMIC_DATA1 */
11  PAD_CFG_NF(GPP_S6, NONE, DEEP, NF2), /* DMIC_CLK0 */
12  PAD_CFG_NF(GPP_S7, NONE, DEEP, NF2), /* DMIC_DATA0 */
13 };
14 
15 static const struct pad_config dmic_disable_pads[] = {
16  PAD_NC(GPP_S4, NONE),
17  PAD_NC(GPP_S5, NONE),
18  PAD_NC(GPP_S6, NONE),
19  PAD_NC(GPP_S7, NONE),
20 };
21 
22 static const struct pad_config sndw_enable_pads[] = {
23  PAD_CFG_NF(GPP_S0, NONE, DEEP, NF1), /* SNDW0_CLK */
24  PAD_CFG_NF(GPP_S1, NONE, DEEP, NF1), /* SNDW0_DATA */
25  PAD_CFG_NF(GPP_S2, NONE, DEEP, NF1), /* SNDW1_CLK */
26  PAD_CFG_NF(GPP_S3, NONE, DEEP, NF1), /* SNDW1_DATA */
27 };
28 
29 static const struct pad_config sndw_disable_pads[] = {
30  PAD_NC(GPP_S0, NONE),
31  PAD_NC(GPP_S1, NONE),
32  PAD_NC(GPP_S2, NONE),
33  PAD_NC(GPP_S3, NONE),
34 };
35 
36 static const struct pad_config i2s_up3_enable_pads[] = {
37  PAD_CFG_NF(GPP_A23, NONE, DEEP, NF1), /* I2S1_SCLK */
38  PAD_CFG_NF(GPP_D19, NONE, DEEP, NF1), /* I2S_MCLK1 */
39  PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), /* I2S0_SCLK */
40  PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), /* I2S0_SFRM */
41  PAD_CFG_NF(GPP_R2, DN_20K, DEEP, NF2), /* I2S0_TXD */
42  PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), /* I2S0_RXD */
43  PAD_CFG_NF(GPP_R5, NONE, DEEP, NF2), /* I2S1_RXD */
44  PAD_CFG_NF(GPP_R6, NONE, DEEP, NF2), /* I2S1_TXD */
45  PAD_CFG_NF(GPP_R7, NONE, DEEP, NF2), /* I2S1_SFRM */
46 };
47 
48 static const struct pad_config i2s_up4_enable_pads[] = {
49  PAD_CFG_NF(GPP_A7, NONE, DEEP, NF1), /* I2S2_SCLK */
50  PAD_CFG_NF(GPP_D19, NONE, DEEP, NF1), /* I2S_MCLK1 */
51  PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), /* I2S0_SCLK */
52  PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), /* I2S0_SFRM */
53  PAD_CFG_NF(GPP_R2, DN_20K, DEEP, NF2), /* I2S0_TXD */
54  PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), /* I2S0_RXD */
55 };
56 
57 static const struct pad_config i2s_disable_pads[] = {
60  PAD_NC(GPP_R0, NONE),
61  PAD_NC(GPP_R1, NONE),
62  PAD_NC(GPP_R2, DN_20K),
63  PAD_NC(GPP_R3, NONE),
64  PAD_NC(GPP_R5, NONE),
65  PAD_NC(GPP_R6, NONE),
66  PAD_NC(GPP_R7, NONE),
67 };
68 
69 static const struct pad_config sd_power_enable_pads[] = {
70  PAD_CFG_GPO(GPP_D16, 1, DEEP),
71 };
72 
73 static void fw_config_handle(void *unused)
74 {
75  if (!fw_config_is_provisioned()) {
79  return;
80  }
81 
83  printk(BIOS_INFO, "Configure GPIOs for no audio.\n");
87  }
88  if (fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682_SNDW))) {
89  printk(BIOS_INFO, "Configure GPIOs for SoundWire audio.\n");
93  }
94  if (fw_config_probe(FW_CONFIG(AUDIO, MAX98357_ALC5682I_I2S)) ||
95  fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682I_I2S)) ||
96  fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S)) ||
97  fw_config_probe(FW_CONFIG(AUDIO, RT1011_ALC5682I_I2S))) {
98  printk(BIOS_INFO, "Configure GPIOs for I2S audio on UP3.\n");
102  }
103  if (fw_config_probe(FW_CONFIG(AUDIO, MAX98373_ALC5682I_I2S_UP4))) {
104  printk(BIOS_INFO, "Configure GPIOs for I2S audio on UP4.\n");
108  }
109  if (fw_config_probe(FW_CONFIG(DB_SD, SD_GL9755S)) ||
110  fw_config_probe(FW_CONFIG(DB_SD, SD_RTS5227S)) ||
111  fw_config_probe(FW_CONFIG(DB_SD, SD_GL9750)) ||
112  fw_config_probe(FW_CONFIG(DB_SD, SD_OZ711LV2LN))) {
113  printk(BIOS_INFO, "Configure GPIOs for SD power enable.\n");
115  }
116 }
#define GPP_S4
#define GPP_R7
#define GPP_S0
#define GPP_S5
#define GPP_R3
#define GPP_R6
#define GPP_R0
#define GPP_S7
#define GPP_A23
#define GPP_S3
#define GPP_A7
#define GPP_S1
#define GPP_S6
#define GPP_R2
#define GPP_R5
#define GPP_S2
#define GPP_D19
#define GPP_D16
#define GPP_R1
@ BS_DEV_ENABLE
Definition: bootstate.h:82
@ BS_ON_ENTRY
Definition: bootstate.h:95
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
#define FW_CONFIG(__field, __option)
Definition: fw_config.h:28
bool fw_config_is_provisioned(void)
Definition: fw_config.c:83
bool fw_config_probe(const struct fw_config *match)
Definition: fw_config.c:62
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fw_config_handle, NULL)
static const struct pad_config i2s_up4_enable_pads[]
Definition: fw_config.c:48
static const struct pad_config sd_power_enable_pads[]
Definition: fw_config.c:69
static const struct pad_config dmic_enable_pads[]
Definition: fw_config.c:8
static const struct pad_config sndw_enable_pads[]
Definition: fw_config.c:22
static const struct pad_config i2s_up3_enable_pads[]
Definition: fw_config.c:36
static void fw_config_handle(void *unused)
Definition: fw_config.c:73
static const struct pad_config i2s_disable_pads[]
Definition: fw_config.c:57
static const struct pad_config dmic_disable_pads[]
Definition: fw_config.c:15
static const struct pad_config sndw_disable_pads[]
Definition: fw_config.c:29
@ AUDIO
Definition: dramc_pi_api.h:49
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_NF(pad, pull, rst, func)
Definition: gpio_defs.h:197
#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