Debian Codegraph @

src/mainboard/google/brya/variants/uldrenite/variant.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <baseboard/gpio.h>
4 #include <baseboard/variants.h>
5 #include <boardid.h>
6 #include <console/console.h>
7 #include <delay.h>
8 #include <fw_config.h>
9 #include <sar.h>
10 #include <soc/bootblock.h>
11 #include <stdlib.h>
12
13 const char *get_wifi_sar_cbfs_filename(void)
14 {
15 return "wifi_sar_0.hex";
16 }
17
18 static const struct pad_config touchscreen_disable_pads[] = {
19 /* A21 : TCHSCR_REPORT_EN */
20 PAD_NC(GPP_A21, NONE),
21 /* B16 : SOC_I2C_TCHSCR_SDA */
22 PAD_NC(GPP_B16, NONE),
23 /* B17 : SOC_I2C_TCHSCR_SCL */
24 PAD_NC(GPP_B17, NONE),
25 /* D15 : TCHSCR_RST_L */
26 PAD_NC(GPP_D15, NONE),
27 /* D16 : TCHSCR_INT_ODL */
28 PAD_NC(GPP_D16, NONE),
29 /* E17 : EN_PP3300_TCHSCR_X */
30 PAD_NC(GPP_E17, NONE),
31 };
32
33 static const struct pad_config lte_disable_pads[] = {
34 /* A8 : WWAN_RF_DISABLE_ODL */
35 PAD_NC(GPP_A8, NONE),
36 /* F12 : WWAN_RST_L */
37 PAD_NC_LOCK(GPP_F12, NONE, LOCK_CONFIG),
38 /* F13 : PLTRST_WWAN# */
39 PAD_NC(GPP_F13, NONE),
40 /* H23 : WWAN_EN */
41 PAD_NC(GPP_H23, NONE),
42 };
43
44 static const struct pad_config ish_uart0_disable_pads[] = {
45 /* A16 : ISH_GP5 ==> NC */
46 PAD_NC_LOCK(GPP_A16, NONE, LOCK_CONFIG),
47 /* B5 : GPP_B5 ==> NC */
48 PAD_NC(GPP_B5, NONE),
49 /* B6 : GPP_B6 ==> NC */
50 PAD_NC(GPP_B6, NONE),
51 /* D1 : ISH_GP1 ==> NC */
52 PAD_NC(GPP_D1, NONE),
53 /* D13 : UART0_ISH_RXD ==> NC */
54 PAD_NC(GPP_D13, NONE),
55 /* D14 : UART0_ISH_TXD ==> NC */
56 PAD_NC(GPP_D14, NONE),
57 /* E9 : SOC_ACC2_INT ==> NC */
58 PAD_NC_LOCK(GPP_E9, NONE, LOCK_CONFIG),
59 };
60
61 static const struct pad_config switch_ish_uart1_pads[] = {
62 /* D13 : UART0_ISH_RXD ==> NC */
63 PAD_NC(GPP_D13, NONE),
64 /* D14 : UART0_ISH_TXD ==> NC */
65 PAD_NC(GPP_D14, NONE),
66 /* D17 : NC ==> UART1_ISH_RDX */
67 PAD_CFG_NF(GPP_D17, NONE, DEEP, NF2),
68 /* D18 : NC ==> UART1_ISH_TDX */
69 PAD_CFG_NF(GPP_D18, NONE, DEEP, NF2),
70 };
71
72 static const struct pad_config ish_uart1_disable_pads[] = {
73 /* A16 : ISH_GP5 ==> NC */
74 PAD_NC_LOCK(GPP_A16, NONE, LOCK_CONFIG),
75 /* B5 : GPP_B5 ==> NC */
76 PAD_NC(GPP_B5, NONE),
77 /* B6 : GPP_B6 ==> NC */
78 PAD_NC(GPP_B6, NONE),
79 /* D1 : ISH_GP1 ==> NC */
80 PAD_NC(GPP_D1, NONE),
81 /* D17 : UART1_ISH_RDX ==> NC */
82 PAD_NC(GPP_D17, NONE),
83 /* D18 : UART1_ISH_TDX ==> NC*/
84 PAD_NC(GPP_D18, NONE),
85 /* E9 : SOC_ACC2_INT ==> NC */
86 PAD_NC_LOCK(GPP_E9, NONE, LOCK_CONFIG),
87 };
88
89 static const struct pad_config emmc_disable_pads[] = {
90 /* I7 : EMMC_CMD */
91 PAD_NC(GPP_I7, NONE),
92 /* I8 : EMMC_D0 */
93 PAD_NC(GPP_I8, NONE),
94 /* I9 : EMMC_D1 */
95 PAD_NC(GPP_I9, NONE),
96 /* I10 : EMMC_D2 */
97 PAD_NC(GPP_I10, NONE),
98 /* I11 : EMMC_D3 */
99 PAD_NC(GPP_I11, NONE),
100 /* I12 : EMMC_D4 */
101 PAD_NC(GPP_I12, NONE),
102 /* I13 : EMMC_D5 */
103 PAD_NC(GPP_I13, NONE),
104 /* I14 : EMMC_D6 */
105 PAD_NC(GPP_I14, NONE),
106 /* I15 : EMMC_D7 */
107 PAD_NC(GPP_I15, NONE),
108 /* I16 : EMMC_RCLK */
109 PAD_NC(GPP_I16, NONE),
110 /* I17 : EMMC_CLK */
111 PAD_NC(GPP_I17, NONE),
112 /* I18 : EMMC_RST_L */
113 PAD_NC(GPP_I18, NONE),
114 };
115
116 void fw_config_gpio_padbased_override(struct pad_config *padbased_table)
117 {
118 uint32_t board_version = board_id();
119
120 if (fw_config_probe(FW_CONFIG(TOUCHSCREEN, TOUCHSCREEN_NONE))) {
121 printk(BIOS_INFO, "Disable touchscreen GPIO pins.\n");
122 gpio_padbased_override(padbased_table, touchscreen_disable_pads,
123 ARRAY_SIZE(touchscreen_disable_pads));
124 }
125 if (fw_config_probe(FW_CONFIG(DB_CELLULAR, CELLULAR_ABSENT))) {
126 printk(BIOS_INFO, "Disable Cellular GPIO pins.\n");
127 gpio_padbased_override(padbased_table, lte_disable_pads,
128 ARRAY_SIZE(lte_disable_pads));
129 }
130 if (fw_config_probe(FW_CONFIG(STORAGE, STORAGE_UFS))) {
131 printk(BIOS_INFO, "Disable eMMC GPIO pins.\n");
132 gpio_padbased_override(padbased_table, emmc_disable_pads,
133 ARRAY_SIZE(emmc_disable_pads));
134 }
135
136 /* b/415605630: Support different ISH UART mappings according the board id */
137 if (board_version < 2) {
138 /* Override ISH UART0 to ISH UART1 */
139 gpio_padbased_override(padbased_table, switch_ish_uart1_pads,
140 ARRAY_SIZE(switch_ish_uart1_pads));
141
142 if (!fw_config_probe(FW_CONFIG(ISH, ISH_ENABLE))) {
143 printk(BIOS_INFO, "Disable ISH GPIO pins is based on ISH UART1.\n");
144 gpio_padbased_override(padbased_table, ish_uart1_disable_pads,
145 ARRAY_SIZE(ish_uart1_disable_pads));
146 }
147 } else {
148 if (!fw_config_probe(FW_CONFIG(ISH, ISH_ENABLE))) {
149 printk(BIOS_INFO, "Disable ISH GPIO pins is based on ISH UART0.\n");
150 gpio_padbased_override(padbased_table, ish_uart0_disable_pads,
151 ARRAY_SIZE(ish_uart0_disable_pads));
152 }
153 }
154 }
155
156 void variant_update_soc_chip_config(struct soc_intel_alderlake_config *config)
157 {
158 if (fw_config_probe(FW_CONFIG(EXT_VR, EXT_VR_PRESENT))) {
159 /* # Configure external V1P05/Vnn/VnnSx Rails */
160 config->ext_fivr_settings.configure_ext_fivr = 1;
161 config->ext_fivr_settings.v1p05_enable_bitmap =
162 FIVR_ENABLE_ALL_SX & ~FIVR_ENABLE_S0;
163 config->ext_fivr_settings.vnn_enable_bitmap =
164 FIVR_ENABLE_ALL_SX;
165 config->ext_fivr_settings.vnn_sx_enable_bitmap =
166 FIVR_ENABLE_ALL_SX;
167 config->ext_fivr_settings.v1p05_supported_voltage_bitmap =
168 FIVR_VOLTAGE_NORMAL;
169 config->ext_fivr_settings.vnn_supported_voltage_bitmap =
170 FIVR_VOLTAGE_MIN_ACTIVE;
171 config->ext_fivr_settings.v1p05_voltage_mv = 1050;
172 config->ext_fivr_settings.vnn_voltage_mv = 780;
173 config->ext_fivr_settings.vnn_sx_voltage_mv = 1050;
174 config->ext_fivr_settings.v1p05_icc_max_ma = 500;
175 config->ext_fivr_settings.vnn_icc_max_ma = 500;
176 printk(BIOS_INFO, "Configured External FIVR\n");
177 }
178 }
179
180 void variant_update_descriptor(void)
181 {
182 uint32_t board_version = board_id();
183
184 /* b/404126972: Only this phase has M/B with both FIVR and MBVR. */
185 if (board_version != 1)
186 return;
187
188 /* VccanaVrLocation = "VCCANA is CPU FIVR" */
189 struct descriptor_byte fivr_bytes[] = {
190 { 0xc33, 0x32 }
191 };
192
193 /* VccanaVrLocation = "VCCANA is Platform VR" */
194 struct descriptor_byte mbvr_bytes[] = {
195 { 0xc33, 0x72 }
196 };
197
198 if (fw_config_probe(FW_CONFIG(EXT_VR, EXT_VR_PRESENT))) {
199 printk(BIOS_INFO, "Configuring descriptor for MBVR\n");
200 configure_descriptor(mbvr_bytes, ARRAY_SIZE(mbvr_bytes));
201 } else {
202 printk(BIOS_INFO, "Configuring descriptor for FIVR\n");
203 configure_descriptor(fivr_bytes, ARRAY_SIZE(fivr_bytes));
204 }
205 }
206
207 void variant_configure_pads(void)
208 {
209 const struct pad_config *base_pads;
210 struct pad_config *padbased_table;
211 size_t base_num;
212
213 padbased_table = new_padbased_table();
214 base_pads = variant_gpio_table(&base_num);
215 gpio_padbased_override(padbased_table, base_pads, base_num);
216 fw_config_gpio_padbased_override(padbased_table);
217 gpio_configure_pads_with_padbased(padbased_table);
218 free(padbased_table);
219 }