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_R4, NONE, DEEP, NF3), /* DMIC_CLK0_R */
10  PAD_CFG_NF(GPP_R5, NONE, DEEP, NF3), /* DMIC_DATA0_R */
11  PAD_CFG_NF(GPP_R6, NONE, DEEP, NF3), /* DMIC_CLK1_R */
12  PAD_CFG_NF(GPP_R7, NONE, DEEP, NF3), /* DMIC_DATA1_R */
13 };
14 
15 static const struct pad_config dmic_disable_pads[] = {
16  PAD_NC(GPP_R4, NONE),
17  PAD_NC(GPP_R5, NONE),
18  PAD_NC(GPP_R6, NONE),
19  PAD_NC(GPP_R7, NONE),
20 };
21 
22 static const struct pad_config i2s_enable_pads[] = {
23  PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), /* I2S_HP_SCLK_R */
24  PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), /* I2S_HP_SFRM_R */
25  PAD_CFG_NF(GPP_R2, DN_20K, DEEP, NF2), /* I2S_PCH_TX_HP_RX_STRAP */
26  PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), /* I2S_PCH_RX_HP_TX */
27  PAD_CFG_NF(GPP_S0, NONE, DEEP, NF4), /* I2S_SPKR_SCLK_R */
28  PAD_CFG_NF(GPP_S1, NONE, DEEP, NF4), /* I2S_SPKR_SFRM_R */
29  PAD_CFG_NF(GPP_S2, NONE, DEEP, NF4), /* I2S_PCH_TX_SPKR_RX_R */
30  PAD_CFG_NF(GPP_S3, NONE, DEEP, NF4), /* I2S_PCH_RX_SPKR_TX */
31 };
32 
33 static const struct pad_config i2s_disable_pads[] = {
34  PAD_NC(GPP_R0, NONE),
35  PAD_NC(GPP_R1, NONE),
36  PAD_NC(GPP_R2, NONE),
37  PAD_NC(GPP_R3, NONE),
38  PAD_NC(GPP_S0, NONE),
39  PAD_NC(GPP_S1, NONE),
40  PAD_NC(GPP_S2, NONE),
41  PAD_NC(GPP_S3, NONE),
42 };
43 
44 static const struct pad_config bt_i2s_enable_pads[] = {
45  PAD_CFG_NF(GPP_VGPIO_30, NONE, DEEP, NF3), /* BT_I2S_BCLK */
46  PAD_CFG_NF(GPP_VGPIO_31, NONE, DEEP, NF3), /* BT_I2S_SYNC */
47  PAD_CFG_NF(GPP_VGPIO_32, NONE, DEEP, NF3), /* BT_I2S_SDO */
48  PAD_CFG_NF(GPP_VGPIO_33, NONE, DEEP, NF3), /* BT_I2S_SDI */
49  PAD_CFG_NF(GPP_VGPIO_34, NONE, DEEP, NF1), /* SSP2_SCLK */
50  PAD_CFG_NF(GPP_VGPIO_35, NONE, DEEP, NF1), /* SSP2_SFRM */
51  PAD_CFG_NF(GPP_VGPIO_36, NONE, DEEP, NF1), /* SSP_TXD */
52  PAD_CFG_NF(GPP_VGPIO_37, NONE, DEEP, NF1), /* SSP_RXD */
53 };
54 
55 static const struct pad_config bt_i2s_disable_pads[] = {
64 };
65 
66 
67 static void fw_config_handle(void *unused)
68 {
69  if (!fw_config_is_provisioned() || fw_config_probe(FW_CONFIG(AUDIO, AUDIO_UNKNOWN))) {
70  printk(BIOS_INFO, "Disable audio related GPIO pins.\n");
74  return;
75  }
76 
77  if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S))) {
78  printk(BIOS_INFO, "Configure audio over I2S with MAX98360 ALC5682I.\n");
82  }
83 
84  if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_VS_I2S))) {
85  printk(BIOS_INFO, "Configure audio over I2S with MAX98360 ALC5682I-VS.\n");
89  }
90 }
#define GPP_VGPIO_37
#define GPP_VGPIO_32
#define GPP_R4
#define GPP_R7
#define GPP_S0
#define GPP_R3
#define GPP_R6
#define GPP_R0
#define GPP_S3
#define GPP_VGPIO_36
#define GPP_S1
#define GPP_VGPIO_31
#define GPP_R2
#define GPP_R5
#define GPP_S2
#define GPP_VGPIO_34
#define GPP_VGPIO_35
#define GPP_VGPIO_30
#define GPP_VGPIO_33
#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 dmic_enable_pads[]
Definition: fw_config.c:8
static const struct pad_config bt_i2s_disable_pads[]
Definition: fw_config.c:55
static const struct pad_config i2s_enable_pads[]
Definition: fw_config.c:22
static void fw_config_handle(void *unused)
Definition: fw_config.c:67
static const struct pad_config i2s_disable_pads[]
Definition: fw_config.c:33
static const struct pad_config dmic_disable_pads[]
Definition: fw_config.c:15
static const struct pad_config bt_i2s_enable_pads[]
Definition: fw_config.c:44
@ 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 NULL
Definition: stddef.h:19
uint16_t unused
Definition: padconfig.h:13