blob: 6dbf31d2d633c57ef9319a111172601183a687e7 [file] [log] [blame]
Tyler Wang77d8e0b2023-09-05 14:21:19 +08001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <baseboard/variants.h>
4#include <bootstate.h>
5#include <console/console.h>
6#include <fw_config.h>
7#include <gpio.h>
8
9#define GPIO_PADBASED_OVERRIDE(b, a) gpio_padbased_override(b, a, ARRAY_SIZE(a))
10
11static const struct pad_config fp_disable_pads[] = {
12 /* GPP_B11 : [] ==> EN_FP_PWR */
13 PAD_NC(GPP_B11, NONE),
14 /* GPP_C22 : [] ==> SOC_FP_BOOT0 */
15 PAD_NC(GPP_C22, NONE),
16 /* GPP_C23 : [] ==> FP_RST_ODL */
17 PAD_NC(GPP_C23, NONE),
18 /* GPP_E10 : [] ==> SOC_FPMCU_INT_L */
19 PAD_NC(GPP_E10, NONE),
20 /* GPP_F11 : GSP1_SOC_CLK_R */
21 PAD_NC(GPP_F11, NONE),
22 /* GPP_F12 : GSPI1_SOC_DO_FPMCU_DI_R */
23 PAD_NC(GPP_F12, NONE),
24 /* GPP_F13 : GSPI1_SOC_DI_FPMCU_DO_LS_R */
25 PAD_NC(GPP_F13, NONE),
26 /* GPP_F17 : [] ==> GSPI1_SOC_CS_L */
27 PAD_NC(GPP_F17, NONE),
28};
29
30static const struct pad_config stylus_disable_pads[] = {
31 /* GPP_E04 : SOC_PEN_DETECT */
32 PAD_NC(GPP_E04, NONE),
Tyler Wangb1be5c22023-11-21 19:47:26 +080033 /* GPP_E09 : SOC_PEN_DETECT */
34 PAD_NC(GPP_E09, NONE),
Tyler Wang77d8e0b2023-09-05 14:21:19 +080035};
36
Tyler Wangb24eadb2023-11-21 15:38:57 +080037static const struct pad_config cnvi_bt_disable_pads[] = {
Tyler Wang25807fd2023-12-29 15:19:22 +080038 /* GPP_F00 : [] ==> CNV_BRI_DT_R */
39 PAD_NC(GPP_F00, NONE),
40 /* GPP_F01 : [] ==> CNV_BRI_RSP */
41 PAD_NC(GPP_F01, NONE),
42 /* GPP_F02 : [] ==> CNV_RGI_DT_Rl */
43 PAD_NC(GPP_F02, NONE),
44 /* GPP_F03 : [] ==> CNV_RGI_RSP */
45 PAD_NC(GPP_F03, NONE),
46 /* GPP_F04 : [] ==> CNV_RF_RST_L */
Tyler Wangb24eadb2023-11-21 15:38:57 +080047 PAD_NC(GPP_F04, NONE),
Tyler Wang25807fd2023-12-29 15:19:22 +080048 /* GPP_F05 : [] ==> CNV_CLKREQ */
Tyler Wangb24eadb2023-11-21 15:38:57 +080049 PAD_NC(GPP_F05, NONE),
50};
51
Tyler Wang25807fd2023-12-29 15:19:22 +080052static const struct pad_config discrete_bt_disable_pads[] = {
53 /* GPP_S01 : [] ==> SDW_HP_DATA_WLAN_PCM_SYNC */
54 PAD_NC(GPP_S01, NONE),
55 /* GPP_S02 : [] ==> DMIC_SOC_CLK0_WLAN_PCM_OUT */
56 PAD_NC(GPP_S02, NONE),
57 /* GPP_D21 : [] ==> WLAN_CLKREQ_ODLl */
58 PAD_NC(GPP_D21, NONE),
59};
60
Tyler Wangb24eadb2023-11-21 15:38:57 +080061static const struct pad_config bt_i2s_enable_pads[] = {
62 /* GPP_V30 : [] ==> BT_I2S_BCLK */
63 PAD_CFG_NF(GPP_VGPIO30, NONE, DEEP, NF2),
64 /* GPP_V31 : [] ==> BT_I2S_SYNC */
65 PAD_CFG_NF(GPP_VGPIO31, NONE, DEEP, NF2),
66 /* GPP_V32 : [] ==> BT_I2S_SDO */
67 PAD_CFG_NF(GPP_VGPIO32, NONE, DEEP, NF2),
68 /* GPP_V33 : [] ==> BT_I2S_SDI */
69 PAD_CFG_NF(GPP_VGPIO33, NONE, DEEP, NF2),
70 /* GPP_V34 : [] ==> SSP2_SCLK */
71 PAD_CFG_NF(GPP_VGPIO34, NONE, DEEP, NF1),
72 /* GPP_V35 : [] ==> SSP2_SFRM */
73 PAD_CFG_NF(GPP_VGPIO35, NONE, DEEP, NF1),
74 /* GPP_V36 : [] ==> SSP_TXD */
75 PAD_CFG_NF(GPP_VGPIO36, NONE, DEEP, NF1),
76 /* GPP_V37 : [] ==> SSP_RXD */
77 PAD_CFG_NF(GPP_VGPIO37, NONE, DEEP, NF1),
78};
79
80static const struct pad_config discrete_bt_i2s_enable_pads[] = {
81 /* GPP_S00 : [] ==> I2S1_SCLK */
82 PAD_CFG_NF(GPP_S00, NONE, DEEP, NF6),
83 /* GPP_S01 : [] ==> I2S1_SFRM */
84 PAD_CFG_NF(GPP_S01, NONE, DEEP, NF6),
85 /* GPP_S02 : [] ==> I2S1_TXD */
86 PAD_CFG_NF(GPP_S02, NONE, DEEP, NF6),
87 /* GPP_S03 : [] ==> I2S1_RXD */
88 PAD_CFG_NF(GPP_S03, NONE, DEEP, NF6),
89};
90
Tyler Wang77d8e0b2023-09-05 14:21:19 +080091void fw_config_gpio_padbased_override(struct pad_config *padbased_table)
92{
93 if (fw_config_probe(FW_CONFIG(STYLUS, STYLUS_ABSENT))) {
94 printk(BIOS_INFO, "Configure GPIOs for no stylus.\n");
95 GPIO_PADBASED_OVERRIDE(padbased_table, stylus_disable_pads);
96 }
97 if (fw_config_probe(FW_CONFIG(FP_MCU, FP_ABSENT))) {
98 printk(BIOS_INFO, "Configure GPIOs for no FP module.\n");
99 GPIO_PADBASED_OVERRIDE(padbased_table, fp_disable_pads);
100 }
Tyler Wangb24eadb2023-11-21 15:38:57 +0800101 if (fw_config_probe(FW_CONFIG(WIFI_TYPE, WIFI_CNVI))) {
102 printk(BIOS_INFO, "Configure GPIOs for CNVi WIFI/BT module.\n");
103 GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads);
Tyler Wang25807fd2023-12-29 15:19:22 +0800104 printk(BIOS_INFO, "Disable GPIOs for PCIe WIFI/BT module.\n");
105 GPIO_PADBASED_OVERRIDE(padbased_table, discrete_bt_disable_pads);
Tyler Wangb24eadb2023-11-21 15:38:57 +0800106 }
107 if (fw_config_probe(FW_CONFIG(WIFI_TYPE, WIFI_PCIE))) {
108 printk(BIOS_INFO, "Configure GPIOs for discrete WIFI/BT module.\n");
109 GPIO_PADBASED_OVERRIDE(padbased_table, discrete_bt_i2s_enable_pads);
110 printk(BIOS_INFO, "Configure GPIOs for discrete PCM BT path.\n");
111 GPIO_PADBASED_OVERRIDE(padbased_table, cnvi_bt_disable_pads);
112 }
Tyler Wang77d8e0b2023-09-05 14:21:19 +0800113}