Debian Codegraph @

src/mainboard/google/rex/variants/rex0/fw_config.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <baseboard/variants.h>
4 #include <console/console.h>
5 #include <fw_config.h>
6 #include <gpio.h>
7
8 #define GPIO_PADBASED_OVERRIDE(b, a) gpio_padbased_override(b, a, ARRAY_SIZE(a))
9
10 static const struct pad_config dmic_disable_pads[] = {
11 PAD_NC(GPP_S02, NONE),
12 PAD_NC(GPP_S03, NONE),
13 PAD_NC(GPP_S06, NONE),
14 PAD_NC(GPP_S07, NONE),
15 };
16
17 static const struct pad_config sndw_disable_pads[] = {
18 PAD_NC(GPP_S00, NONE),
19 PAD_NC(GPP_S01, NONE),
20 PAD_NC(GPP_S04, NONE),
21 PAD_NC(GPP_S05, NONE),
22 };
23
24 static const struct pad_config i2s_disable_pads[] = {
25 PAD_NC(GPP_D09, NONE),
26 PAD_NC(GPP_D10, NONE),
27 PAD_NC(GPP_D11, NONE),
28 PAD_NC(GPP_D12, DN_20K),
29 PAD_NC(GPP_D13, NONE),
30 PAD_NC(GPP_D14, NONE),
31 PAD_NC(GPP_D15, NONE),
32 PAD_NC(GPP_D16, NONE),
33 PAD_NC(GPP_D17, NONE),
34 };
35
36 static const struct pad_config bt_i2s_enable_pads[] = {
37 /* GPP_V30 : [] ==> BT_I2S_BCLK */
38 PAD_CFG_NF(GPP_VGPIO30, NONE, DEEP, NF2),
39 /* GPP_V31 : [] ==> BT_I2S_SYNC */
40 PAD_CFG_NF(GPP_VGPIO31, NONE, DEEP, NF2),
41 /* GPP_V32 : [] ==> BT_I2S_SDO */
42 PAD_CFG_NF(GPP_VGPIO32, NONE, DEEP, NF2),
43 /* GPP_V33 : [] ==> BT_I2S_SDI */
44 PAD_CFG_NF(GPP_VGPIO33, NONE, DEEP, NF2),
45 /* GPP_V34 : [] ==> SSP2_SCLK */
46 PAD_CFG_NF(GPP_VGPIO34, NONE, DEEP, NF1),
47 /* GPP_V35 : [] ==> SSP2_SFRM */
48 PAD_CFG_NF(GPP_VGPIO35, NONE, DEEP, NF1),
49 /* GPP_V36 : [] ==> SSP_TXD */
50 PAD_CFG_NF(GPP_VGPIO36, NONE, DEEP, NF1),
51 /* GPP_V37 : [] ==> SSP_RXD */
52 PAD_CFG_NF(GPP_VGPIO37, NONE, DEEP, NF1),
53 };
54
55 static const struct pad_config discrete_bt_i2s_enable_pads[] = {
56 /* GPP_S00 : [] ==> I2S1_SCLK */
57 PAD_CFG_NF(GPP_S00, NONE, DEEP, NF6),
58 /* GPP_S01 : [] ==> I2S1_SFRM */
59 PAD_CFG_NF(GPP_S01, NONE, DEEP, NF6),
60 /* GPP_S02 : [] ==> I2S1_TXD */
61 PAD_CFG_NF(GPP_S02, NONE, DEEP, NF6),
62 /* GPP_S03 : [] ==> I2S1_RXD */
63 PAD_CFG_NF(GPP_S03, NONE, DEEP, NF6),
64 };
65
66 static const struct pad_config bt_i2s_disable_pads[] = {
67 /* GPP_V30 : [] ==> BT_I2S_BCLK */
68 PAD_NC(GPP_VGPIO30, NONE),
69 /* GPP_V31 : [] ==> BT_I2S_SYNC */
70 PAD_NC(GPP_VGPIO31, NONE),
71 /* GPP_V32 : [] ==> BT_I2S_SDO */
72 PAD_NC(GPP_VGPIO32, NONE),
73 /* GPP_V33 : [] ==> BT_I2S_SDI */
74 PAD_NC(GPP_VGPIO33, NONE),
75 /* GPP_V34 : [] ==> SSP2_SCLK */
76 PAD_NC(GPP_VGPIO34, NONE),
77 /* GPP_V35 : [] ==> SSP2_SFRM */
78 PAD_NC(GPP_VGPIO35, NONE),
79 /* GPP_V36 : [] ==> SSP_TXD */
80 PAD_NC(GPP_VGPIO36, NONE),
81 /* GPP_V37 : [] ==> SSP_RXD */
82 PAD_NC(GPP_VGPIO37, NONE),
83 };
84
85 static const struct pad_config ish_enable_pads[] = {
86 /* GPP_B02 : ISH I2C0_SDA */
87 PAD_CFG_NF_IOSTANDBY_IGNORE(GPP_B02, NONE, DEEP, NF3),
88 /* GPP_B03 : ISH_I2C0_SCL */
89 PAD_CFG_NF_IOSTANDBY_IGNORE(GPP_B03, NONE, DEEP, NF3),
90 /* GPP_B08 : ISH_GP3, SOC_ISH_ACCEL_INT_L */
91 PAD_CFG_NF(GPP_B08, NONE, DEEP, NF4),
92 /* GPP_E15 : ISH_GP5A, SOC_ISH_IMU_INT_L */
93 PAD_CFG_NF(GPP_E15, NONE, DEEP, NF8),
94 /* GPP_E16 : ISH_GP10, SOC_EC_ISH_NB_MODE */
95 PAD_CFG_NF(GPP_E16, NONE, DEEP, NF8),
96 /* GPP_F22 : ISH_GP8A, SOC_ISH_ALS_INT_L */
97 PAD_CFG_NF(GPP_F22, NONE, DEEP, NF8),
98 /* GPP_F23 : ISH_GP9A, LID_OPEN_1V8 */
99 PAD_CFG_NF(GPP_F23, NONE, DEEP, NF8),
100 /* GPP_H11 : ISH_GP11A, SOC_ISH_IMU_INT_L */
101 PAD_CFG_NF(GPP_H11, NONE, DEEP, NF8),
102 };
103
104 static const struct pad_config touchscreen_i2c_int_pads[] = {
105 /* GPP_C07 : [] ==> SOC_TCHSCR_INT */
106 PAD_CFG_GPI_APIC(GPP_C07, NONE, PLTRST, LEVEL, NONE),
107 };
108
109 static const struct pad_config touchscreen_spi_int_pads[] = {
110 /* GPP_C07 : [] ==> SOC_TCHSCR_INT */
111 PAD_CFG_GPI_APIC(GPP_C07, NONE, PLTRST, EDGE_SINGLE, INVERT),
112 };
113
114 static const struct pad_config uwb_gspi1_enable_pads[] = {
115 PAD_CFG_GPO_LOCK(GPP_D07, 0, LOCK_CONFIG), /* FPMCU_UWB_MUX_SEL */
116 PAD_CFG_GPO(GPP_E06, 0, DEEP), /* UWB_SOC_SYNC */
117 PAD_CFG_GPO(GPP_F19, 0, DEEP), /* EN_PP1800_UWB */
118 PAD_CFG_GPI_INT(GPP_F20, NONE, PLTRST, LEVEL), /* UWB_SOC_INT */
119 };
120
121 static const struct pad_config uwb_gspi1_disable_pads[] = {
122 PAD_CFG_GPO_LOCK(GPP_D07, 1, LOCK_CONFIG), /* FPMCU_UWB_MUX_SEL */
123 PAD_NC(GPP_E06, NONE),
124 PAD_NC(GPP_F19, NONE),
125 PAD_NC(GPP_F20, NONE),
126 };
127
128 static const struct pad_config wwan_disable_pads[] = {
129 PAD_CFG_GPO(GPP_B17, 0, DEEP) /* EN_WWAN_PWR */
130 };
131
132 void fw_config_gpio_padbased_override(struct pad_config *padbased_table)
133 {
134 if (!fw_config_is_provisioned()) {
135 GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads);
136 GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads);
137 GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads);
138 GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads);
139 return;
140 }
141
142 if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_UNKNOWN))) {
143 printk(BIOS_INFO, "Configure GPIOs for no audio.\n");
144 GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads);
145 GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads);
146 GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads);
147 GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_disable_pads);
148 } else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98363_CS42L42_SNDW))) {
149 printk(BIOS_INFO, "Configure GPIOs for SoundWire audio.\n");
150 GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads);
151 printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n");
152 GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads);
153 } else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S))) {
154 printk(BIOS_INFO, "Configure GPIOs for I2S audio.\n");
155 GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads);
156 printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n");
157 GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads);
158 } else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_DISCRETE_I2S_BT))) {
159 printk(BIOS_INFO, "Configure GPIOs for I2S audio.\n");
160 GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads);
161 printk(BIOS_INFO, "Configure GPIOs for BT offload mode(discrete).\n");
162 GPIO_PADBASED_OVERRIDE(padbased_table, discrete_bt_i2s_enable_pads);
163 }
164
165 if (fw_config_probe(FW_CONFIG(ISH, ISH_ENABLE))) {
166 printk(BIOS_INFO, "Configure GPIOs for ISH.\n");
167 GPIO_PADBASED_OVERRIDE(padbased_table, ish_enable_pads);
168 }
169
170 if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_I2C))) {
171 printk(BIOS_INFO, "Configure Touchscreen Interrupt for I2C.\n");
172 GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_i2c_int_pads);
173 } else { /* SPI */
174 printk(BIOS_INFO, "Configure Touchscreen Interrupt for SPI.\n");
175 GPIO_PADBASED_OVERRIDE(padbased_table, touchscreen_spi_int_pads);
176 }
177
178 if (fw_config_probe(FW_CONFIG(UWB, UWB_GSPI1)) &&
179 fw_config_probe(FW_CONFIG(FP, FP_ABSENT))) {
180 printk(BIOS_INFO, "Configure GPIOs for UWB over GSPI1.\n");
181 GPIO_PADBASED_OVERRIDE(padbased_table, uwb_gspi1_enable_pads);
182 } else {
183 printk(BIOS_INFO, "Disabling UWB (absent or misconfigured)\n");
184 GPIO_PADBASED_OVERRIDE(padbased_table, uwb_gspi1_disable_pads);
185 }
186
187 if (fw_config_probe(FW_CONFIG(CELLULAR, CELLULAR_ABSENT))) {
188 printk(BIOS_INFO, "Configure GPIOs for no cellular.\n");
189 GPIO_PADBASED_OVERRIDE(padbased_table, wwan_disable_pads);
190 }
191 }