1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <baseboard/variants.h>
4 #include <console/console.h>
8 #define GPIO_PADBASED_OVERRIDE(b, a) gpio_padbased_override(b, a, ARRAY_SIZE(a))
10 static const struct pad_config fp_disable_pads
[] = {
11 /* GPP_B11 : [] ==> EN_FP_PWR */
12 PAD_NC(GPP_B11
, NONE
),
13 /* GPP_C22 : [] ==> SOC_FP_BOOT0 */
14 PAD_NC(GPP_C22
, NONE
),
15 /* GPP_C23 : [] ==> FP_RST_ODL */
16 PAD_NC(GPP_C23
, NONE
),
17 /* GPP_E10 : [] ==> SOC_FPMCU_INT_L */
18 PAD_NC(GPP_E10
, NONE
),
19 /* GPP_F11 : GSP1_SOC_CLK_R */
20 PAD_NC(GPP_F11
, NONE
),
21 /* GPP_F12 : GSPI1_SOC_DO_FPMCU_DI_R */
22 PAD_NC(GPP_F12
, NONE
),
23 /* GPP_F13 : GSPI1_SOC_DI_FPMCU_DO_LS_R */
24 PAD_NC(GPP_F13
, NONE
),
25 /* GPP_F17 : [] ==> GSPI1_SOC_CS_L */
26 PAD_NC(GPP_F17
, NONE
),
29 static const struct pad_config stylus_disable_pads
[] = {
30 /* GPP_E04 : SOC_PEN_DETECT */
31 PAD_NC(GPP_E04
, NONE
),
32 /* GPP_E09 : SOC_PEN_DETECT */
33 PAD_NC(GPP_E09
, NONE
),
36 static const struct pad_config cnvi_bt_disable_pads
[] = {
37 /* GPP_F04 : [] ==> CNV_RF_RST_L */
38 PAD_NC(GPP_F04
, NONE
),
39 /* GPP_F05 : [] ==> CNV_CLKREQ */
40 PAD_NC(GPP_F05
, NONE
),
43 static const struct pad_config discrete_bt_disable_pads
[] = {
44 /* GPP_S01 : [] ==> SDW_HP_DATA_WLAN_PCM_SYNC */
45 PAD_NC(GPP_S01
, NONE
),
46 /* GPP_S02 : [] ==> DMIC_SOC_CLK0_WLAN_PCM_OUT */
47 PAD_NC(GPP_S02
, NONE
),
50 static const struct pad_config bt_i2s_enable_pads
[] = {
51 /* GPP_V30 : [] ==> BT_I2S_BCLK */
52 PAD_CFG_NF(GPP_VGPIO30
, NONE
, DEEP
, NF2
),
53 /* GPP_V31 : [] ==> BT_I2S_SYNC */
54 PAD_CFG_NF(GPP_VGPIO31
, NONE
, DEEP
, NF2
),
55 /* GPP_V32 : [] ==> BT_I2S_SDO */
56 PAD_CFG_NF(GPP_VGPIO32
, NONE
, DEEP
, NF2
),
57 /* GPP_V33 : [] ==> BT_I2S_SDI */
58 PAD_CFG_NF(GPP_VGPIO33
, NONE
, DEEP
, NF2
),
59 /* GPP_V34 : [] ==> SSP2_SCLK */
60 PAD_CFG_NF(GPP_VGPIO34
, NONE
, DEEP
, NF1
),
61 /* GPP_V35 : [] ==> SSP2_SFRM */
62 PAD_CFG_NF(GPP_VGPIO35
, NONE
, DEEP
, NF1
),
63 /* GPP_V36 : [] ==> SSP_TXD */
64 PAD_CFG_NF(GPP_VGPIO36
, NONE
, DEEP
, NF1
),
65 /* GPP_V37 : [] ==> SSP_RXD */
66 PAD_CFG_NF(GPP_VGPIO37
, NONE
, DEEP
, NF1
),
69 static const struct pad_config discrete_bt_i2s_enable_pads
[] = {
70 /* GPP_S00 : [] ==> I2S1_SCLK */
71 PAD_CFG_NF(GPP_S00
, NONE
, DEEP
, NF6
),
72 /* GPP_S01 : [] ==> I2S1_SFRM */
73 PAD_CFG_NF(GPP_S01
, NONE
, DEEP
, NF6
),
74 /* GPP_S02 : [] ==> I2S1_TXD */
75 PAD_CFG_NF(GPP_S02
, NONE
, DEEP
, NF6
),
76 /* GPP_S03 : [] ==> I2S1_RXD */
77 PAD_CFG_NF(GPP_S03
, NONE
, DEEP
, NF6
),
80 void fw_config_gpio_padbased_override(struct pad_config
*padbased_table
)
82 if (fw_config_probe(FW_CONFIG(STYLUS
, STYLUS_ABSENT
))) {
83 printk(BIOS_INFO
, "Configure GPIOs for no stylus.\n");
84 GPIO_PADBASED_OVERRIDE(padbased_table
, stylus_disable_pads
);
86 if (fw_config_probe(FW_CONFIG(FP_MCU
, FP_ABSENT
))) {
87 printk(BIOS_INFO
, "Configure GPIOs for no FP module.\n");
88 GPIO_PADBASED_OVERRIDE(padbased_table
, fp_disable_pads
);
90 if (fw_config_probe(FW_CONFIG(WIFI_TYPE
, WIFI_CNVI
))) {
91 printk(BIOS_INFO
, "Configure GPIOs for CNVi WIFI/BT module.\n");
92 GPIO_PADBASED_OVERRIDE(padbased_table
, bt_i2s_enable_pads
);
93 printk(BIOS_INFO
, "Disable GPIOs for PCIe WIFI/BT module.\n");
94 GPIO_PADBASED_OVERRIDE(padbased_table
, discrete_bt_disable_pads
);
96 if (fw_config_probe(FW_CONFIG(WIFI_TYPE
, WIFI_PCIE
))) {
97 printk(BIOS_INFO
, "Configure GPIOs for discrete WIFI/BT module.\n");
98 GPIO_PADBASED_OVERRIDE(padbased_table
, discrete_bt_i2s_enable_pads
);
99 printk(BIOS_INFO
, "Configure GPIOs for discrete PCM BT path.\n");
100 GPIO_PADBASED_OVERRIDE(padbased_table
, cnvi_bt_disable_pads
);