1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <baseboard/variants.h>
4 #include <ec/google/chromeec/ec.h>
5 #include <console/console.h>
9 #define GPIO_PADBASED_OVERRIDE(b, a) gpio_padbased_override(b, a, ARRAY_SIZE(a))
11 static const struct pad_config dmic_disable_pads
[] = {
12 PAD_NC(GPP_S02
, NONE
),
13 PAD_NC(GPP_S03
, NONE
),
14 PAD_NC(GPP_S06
, NONE
),
15 PAD_NC(GPP_S07
, NONE
),
18 static const struct pad_config i2s_disable_pads
[] = {
19 PAD_NC(GPP_D09
, NONE
),
20 PAD_NC(GPP_D10
, NONE
),
21 PAD_NC(GPP_D11
, NONE
),
22 PAD_NC(GPP_D12
, DN_20K
),
23 PAD_NC(GPP_D13
, NONE
),
24 PAD_NC(GPP_D14
, NONE
),
25 PAD_NC(GPP_D15
, NONE
),
26 PAD_NC(GPP_D16
, NONE
),
27 PAD_NC(GPP_D17
, NONE
),
31 static const struct pad_config bt_i2s_enable_pads
[] = {
32 /* GPP_V30 : [] ==> BT_I2S_BCLK */
33 PAD_CFG_NF(GPP_VGPIO30
, NONE
, DEEP
, NF2
),
34 /* GPP_V31 : [] ==> BT_I2S_SYNC */
35 PAD_CFG_NF(GPP_VGPIO31
, NONE
, DEEP
, NF2
),
36 /* GPP_V32 : [] ==> BT_I2S_SDO */
37 PAD_CFG_NF(GPP_VGPIO32
, NONE
, DEEP
, NF2
),
38 /* GPP_V33 : [] ==> BT_I2S_SDI */
39 PAD_CFG_NF(GPP_VGPIO33
, NONE
, DEEP
, NF2
),
40 /* GPP_V34 : [] ==> SSP2_SCLK */
41 PAD_CFG_NF(GPP_VGPIO34
, NONE
, DEEP
, NF1
),
42 /* GPP_V35 : [] ==> SSP2_SFRM */
43 PAD_CFG_NF(GPP_VGPIO35
, NONE
, DEEP
, NF1
),
44 /* GPP_V36 : [] ==> SSP_TXD */
45 PAD_CFG_NF(GPP_VGPIO36
, NONE
, DEEP
, NF1
),
46 /* GPP_V37 : [] ==> SSP_RXD */
47 PAD_CFG_NF(GPP_VGPIO37
, NONE
, DEEP
, NF1
),
50 static const struct pad_config bt_i2s_disable_pads
[] = {
51 /* GPP_V30 : [] ==> BT_I2S_BCLK */
52 PAD_NC(GPP_VGPIO30
, NONE
),
53 /* GPP_V31 : [] ==> BT_I2S_SYNC */
54 PAD_NC(GPP_VGPIO31
, NONE
),
55 /* GPP_V32 : [] ==> BT_I2S_SDO */
56 PAD_NC(GPP_VGPIO32
, NONE
),
57 /* GPP_V33 : [] ==> BT_I2S_SDI */
58 PAD_NC(GPP_VGPIO33
, NONE
),
59 /* GPP_V34 : [] ==> SSP2_SCLK */
60 PAD_NC(GPP_VGPIO34
, NONE
),
61 /* GPP_V35 : [] ==> SSP2_SFRM */
62 PAD_NC(GPP_VGPIO35
, NONE
),
63 /* GPP_V36 : [] ==> SSP_TXD */
64 PAD_NC(GPP_VGPIO36
, NONE
),
65 /* GPP_V37 : [] ==> SSP_RXD */
66 PAD_NC(GPP_VGPIO37
, NONE
),
69 static const struct pad_config usb_oc2_gpio_pads
[] = {
70 PAD_CFG_NF_LOCK(GPP_B14
, UP_20K
, NF1
, LOCK_CONFIG
),
73 void fw_config_gpio_padbased_override(struct pad_config
*padbased_table
)
76 google_chromeec_get_board_version(&id
);
77 if (id
== 2 || id
== 1) {
78 printk(BIOS_INFO
, "Configure GPIOs for evt and dvt1.\n");
79 GPIO_PADBASED_OVERRIDE(padbased_table
, usb_oc2_gpio_pads
);
82 if (!fw_config_is_provisioned()) {
83 GPIO_PADBASED_OVERRIDE(padbased_table
, i2s_disable_pads
);
84 GPIO_PADBASED_OVERRIDE(padbased_table
, dmic_disable_pads
);
85 GPIO_PADBASED_OVERRIDE(padbased_table
, bt_i2s_disable_pads
);
89 if (fw_config_probe(FW_CONFIG(AUDIO
, AUDIO_UNKNOWN
))) {
90 printk(BIOS_INFO
, "Configure GPIOs for no audio.\n");
91 GPIO_PADBASED_OVERRIDE(padbased_table
, i2s_disable_pads
);
92 GPIO_PADBASED_OVERRIDE(padbased_table
, dmic_disable_pads
);
93 GPIO_PADBASED_OVERRIDE(padbased_table
, bt_i2s_disable_pads
);
94 } else if (fw_config_probe(FW_CONFIG(AUDIO
, ALC1019_ALC5682I_I2S
))) {
95 printk(BIOS_INFO
, "Configure GPIOs for BT offload mode.\n");
96 GPIO_PADBASED_OVERRIDE(padbased_table
, bt_i2s_enable_pads
);