blob: c48ac0738575789841b7f993258ba91e21522208 [file] [log] [blame]
Simon Glass4a56f102015-01-27 22:13:47 -07001/*
2 * Copyright (C) 2013, Intel Corporation
3 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
Andrew Bradford74fdb582015-08-07 08:36:35 -04004 * Copyright (C) 2015, Kodak Alaris, Inc
Simon Glass4a56f102015-01-27 22:13:47 -07005 *
6 * SPDX-License-Identifier: Intel
7 */
8
9#include <common.h>
Andrew Bradford74fdb582015-08-07 08:36:35 -040010#include <fdtdec.h>
Simon Glass4a56f102015-01-27 22:13:47 -070011#include <asm/arch/fsp/azalia.h>
12#include <asm/fsp/fsp_support.h>
13
Andrew Bradford74fdb582015-08-07 08:36:35 -040014DECLARE_GLOBAL_DATA_PTR;
15
Simon Glass4a56f102015-01-27 22:13:47 -070016/* ALC262 Verb Table - 10EC0262 */
17static const uint32_t verb_table_data13[] = {
18 /* Pin Complex (NID 0x11) */
19 0x01171cf0,
20 0x01171d11,
21 0x01171e11,
22 0x01171f41,
23 /* Pin Complex (NID 0x12) */
24 0x01271cf0,
25 0x01271d11,
26 0x01271e11,
27 0x01271f41,
28 /* Pin Complex (NID 0x14) */
29 0x01471c10,
30 0x01471d40,
31 0x01471e01,
32 0x01471f01,
33 /* Pin Complex (NID 0x15) */
34 0x01571cf0,
35 0x01571d11,
36 0x01571e11,
37 0x01571f41,
38 /* Pin Complex (NID 0x16) */
39 0x01671cf0,
40 0x01671d11,
41 0x01671e11,
42 0x01671f41,
43 /* Pin Complex (NID 0x18) */
44 0x01871c20,
45 0x01871d98,
46 0x01871ea1,
47 0x01871f01,
48 /* Pin Complex (NID 0x19) */
49 0x01971c21,
50 0x01971d98,
51 0x01971ea1,
52 0x01971f02,
53 /* Pin Complex (NID 0x1A) */
54 0x01a71c2f,
55 0x01a71d30,
56 0x01a71e81,
57 0x01a71f01,
58 /* Pin Complex */
59 0x01b71c1f,
60 0x01b71d40,
61 0x01b71e21,
62 0x01b71f02,
63 /* Pin Complex */
64 0x01c71cf0,
65 0x01c71d11,
66 0x01c71e11,
67 0x01c71f41,
68 /* Pin Complex */
69 0x01d71c01,
70 0x01d71dc6,
71 0x01d71e14,
72 0x01d71f40,
73 /* Pin Complex */
74 0x01e71cf0,
75 0x01e71d11,
76 0x01e71e11,
77 0x01e71f41,
78 /* Pin Complex */
79 0x01f71cf0,
80 0x01f71d11,
81 0x01f71e11,
82 0x01f71f41,
83};
84
85/*
86 * This needs to be in ROM since if we put it in CAR, FSP init loses it when
87 * it drops CAR.
88 *
89 * TODO(sjg@chromium.org): Move to device tree when FSP allows it
90 *
91 * VerbTable: (RealTek ALC262)
92 * Revision ID = 0xFF, support all steps
93 * Codec Verb Table For AZALIA
94 * Codec Address: CAd value (0/1/2)
95 * Codec Vendor: 0x10EC0262
96 */
97static const struct pch_azalia_verb_table azalia_verb_table[] = {
98 {
99 {
100 0x10ec0262,
101 0x0000,
102 0xff,
103 0x01,
104 0x000b,
105 0x0002,
106 },
107 verb_table_data13
108 }
109};
110
111const struct pch_azalia_config azalia_config = {
112 .pme_enable = 1,
113 .docking_supported = 1,
114 .docking_attached = 0,
115 .hdmi_codec_enable = 1,
116 .azalia_v_ci_enable = 1,
117 .rsvdbits = 0,
118 .azalia_verb_table_num = 1,
119 .azalia_verb_table = azalia_verb_table,
120 .reset_wait_timer_us = 300
121};
122
Andrew Bradford74fdb582015-08-07 08:36:35 -0400123/**
Bin Mengc24aebd2015-12-10 22:03:00 -0800124 * Override the FSP's configuration data.
Andrew Bradford74fdb582015-08-07 08:36:35 -0400125 * If the device tree does not specify an integer setting, use the default
126 * provided in Intel's Baytrail_FSP_Gold4.tgz release FSP/BayleyBayFsp.bsf file.
127 */
Bin Meng4a076fe2015-12-10 22:03:04 -0800128void update_fsp_configs(struct fsp_config_data *config,
129 struct fspinit_rtbuf *rt_buf)
Simon Glass4a56f102015-01-27 22:13:47 -0700130{
Bin Mengc24aebd2015-12-10 22:03:00 -0800131 struct upd_region *fsp_upd = &config->fsp_upd;
Simon Glass4a56f102015-01-27 22:13:47 -0700132 struct memory_down_data *mem;
Andrew Bradford74fdb582015-08-07 08:36:35 -0400133 const void *blob = gd->fdt_blob;
134 int node;
Simon Glass4a56f102015-01-27 22:13:47 -0700135
Bin Meng4a076fe2015-12-10 22:03:04 -0800136 /* Initialize runtime buffer for fsp_init() */
137 rt_buf->common.stack_top = config->common.stack_top - 32;
138 rt_buf->common.boot_mode = config->common.boot_mode;
139 rt_buf->common.upd_data = &config->fsp_upd;
140
Simon Glass4a56f102015-01-27 22:13:47 -0700141 fsp_upd->azalia_config_ptr = (uint32_t)&azalia_config;
Andrew Bradford74fdb582015-08-07 08:36:35 -0400142
143 node = fdtdec_next_compatible(blob, 0, COMPAT_INTEL_BAYTRAIL_FSP);
144 if (node < 0) {
145 debug("%s: Cannot find FSP node\n", __func__);
146 return;
147 }
148
149 fsp_upd->mrc_init_tseg_size = fdtdec_get_int(blob, node,
150 "fsp,mrc-init-tseg-size",
Bin Meng497c5162017-05-31 01:04:14 -0700151 MRC_INIT_TSEG_SIZE_1MB);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400152 fsp_upd->mrc_init_mmio_size = fdtdec_get_int(blob, node,
153 "fsp,mrc-init-mmio-size",
Bin Meng497c5162017-05-31 01:04:14 -0700154 MRC_INIT_MMIO_SIZE_2048MB);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400155 fsp_upd->mrc_init_spd_addr1 = fdtdec_get_int(blob, node,
156 "fsp,mrc-init-spd-addr1",
157 0xa0);
158 fsp_upd->mrc_init_spd_addr2 = fdtdec_get_int(blob, node,
159 "fsp,mrc-init-spd-addr2",
160 0xa2);
161 fsp_upd->emmc_boot_mode = fdtdec_get_int(blob, node,
Bin Meng497c5162017-05-31 01:04:14 -0700162 "fsp,emmc-boot-mode",
163 EMMC_BOOT_MODE_EMMC41);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400164 fsp_upd->enable_sdio = fdtdec_get_bool(blob, node, "fsp,enable-sdio");
165 fsp_upd->enable_sdcard = fdtdec_get_bool(blob, node,
166 "fsp,enable-sdcard");
167 fsp_upd->enable_hsuart0 = fdtdec_get_bool(blob, node,
168 "fsp,enable-hsuart0");
169 fsp_upd->enable_hsuart1 = fdtdec_get_bool(blob, node,
170 "fsp,enable-hsuart1");
171 fsp_upd->enable_spi = fdtdec_get_bool(blob, node, "fsp,enable-spi");
172 fsp_upd->enable_sata = fdtdec_get_bool(blob, node, "fsp,enable-sata");
Bin Meng497c5162017-05-31 01:04:14 -0700173 fsp_upd->sata_mode = fdtdec_get_int(blob, node, "fsp,sata-mode",
174 SATA_MODE_AHCI);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400175 fsp_upd->enable_azalia = fdtdec_get_bool(blob, node,
176 "fsp,enable-azalia");
177 fsp_upd->enable_xhci = fdtdec_get_bool(blob, node, "fsp,enable-xhci");
178 fsp_upd->enable_lpe = fdtdec_get_bool(blob, node, "fsp,enable-lpe");
179 fsp_upd->lpss_sio_enable_pci_mode = fdtdec_get_bool(blob, node,
180 "fsp,lpss-sio-enable-pci-mode");
181 fsp_upd->enable_dma0 = fdtdec_get_bool(blob, node, "fsp,enable-dma0");
182 fsp_upd->enable_dma1 = fdtdec_get_bool(blob, node, "fsp,enable-dma1");
183 fsp_upd->enable_i2_c0 = fdtdec_get_bool(blob, node, "fsp,enable-i2c0");
184 fsp_upd->enable_i2_c1 = fdtdec_get_bool(blob, node, "fsp,enable-i2c1");
185 fsp_upd->enable_i2_c2 = fdtdec_get_bool(blob, node, "fsp,enable-i2c2");
186 fsp_upd->enable_i2_c3 = fdtdec_get_bool(blob, node, "fsp,enable-i2c3");
187 fsp_upd->enable_i2_c4 = fdtdec_get_bool(blob, node, "fsp,enable-i2c4");
188 fsp_upd->enable_i2_c5 = fdtdec_get_bool(blob, node, "fsp,enable-i2c5");
189 fsp_upd->enable_i2_c6 = fdtdec_get_bool(blob, node, "fsp,enable-i2c6");
190 fsp_upd->enable_pwm0 = fdtdec_get_bool(blob, node, "fsp,enable-pwm0");
191 fsp_upd->enable_pwm1 = fdtdec_get_bool(blob, node, "fsp,enable-pwm1");
192 fsp_upd->enable_hsi = fdtdec_get_bool(blob, node, "fsp,enable-hsi");
193 fsp_upd->igd_dvmt50_pre_alloc = fdtdec_get_int(blob, node,
Bin Meng497c5162017-05-31 01:04:14 -0700194 "fsp,igd-dvmt50-pre-alloc", IGD_DVMT50_PRE_ALLOC_64MB);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400195 fsp_upd->aperture_size = fdtdec_get_int(blob, node, "fsp,aperture-size",
Bin Meng497c5162017-05-31 01:04:14 -0700196 APERTURE_SIZE_256MB);
197 fsp_upd->gtt_size = fdtdec_get_int(blob, node, "fsp,gtt-size",
198 GTT_SIZE_2MB);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400199 fsp_upd->mrc_debug_msg = fdtdec_get_bool(blob, node,
200 "fsp,mrc-debug-msg");
201 fsp_upd->isp_enable = fdtdec_get_bool(blob, node, "fsp,isp-enable");
202 fsp_upd->scc_enable_pci_mode = fdtdec_get_bool(blob, node,
203 "fsp,scc-enable-pci-mode");
204 fsp_upd->igd_render_standby = fdtdec_get_bool(blob, node,
205 "fsp,igd-render-standby");
206 fsp_upd->txe_uma_enable = fdtdec_get_bool(blob, node,
207 "fsp,txe-uma-enable");
208 fsp_upd->os_selection = fdtdec_get_int(blob, node, "fsp,os-selection",
Bin Meng497c5162017-05-31 01:04:14 -0700209 OS_SELECTION_LINUX);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400210 fsp_upd->emmc45_ddr50_enabled = fdtdec_get_bool(blob, node,
211 "fsp,emmc45-ddr50-enabled");
212 fsp_upd->emmc45_hs200_enabled = fdtdec_get_bool(blob, node,
213 "fsp,emmc45-hs200-enabled");
214 fsp_upd->emmc45_retune_timer_value = fdtdec_get_int(blob, node,
215 "fsp,emmc45-retune-timer-value", 8);
216 fsp_upd->enable_igd = fdtdec_get_bool(blob, node, "fsp,enable-igd");
Simon Glass4a56f102015-01-27 22:13:47 -0700217
218 mem = &fsp_upd->memory_params;
Andrew Bradford74fdb582015-08-07 08:36:35 -0400219 mem->enable_memory_down = fdtdec_get_bool(blob, node,
220 "fsp,enable-memory-down");
221 if (mem->enable_memory_down) {
222 node = fdtdec_next_compatible(blob, node,
223 COMPAT_INTEL_BAYTRAIL_FSP_MDP);
224 if (node < 0) {
225 debug("%s: Cannot find FSP memory-down-params node\n",
226 __func__);
227 } else {
228 mem->dram_speed = fdtdec_get_int(blob, node,
229 "fsp,dram-speed",
Bin Meng497c5162017-05-31 01:04:14 -0700230 DRAM_SPEED_1333MTS);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400231 mem->dram_type = fdtdec_get_int(blob, node,
Bin Meng497c5162017-05-31 01:04:14 -0700232 "fsp,dram-type",
233 DRAM_TYPE_DDR3L);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400234 mem->dimm_0_enable = fdtdec_get_bool(blob, node,
235 "fsp,dimm-0-enable");
236 mem->dimm_1_enable = fdtdec_get_bool(blob, node,
237 "fsp,dimm-1-enable");
238 mem->dimm_width = fdtdec_get_int(blob, node,
239 "fsp,dimm-width",
Bin Meng497c5162017-05-31 01:04:14 -0700240 DIMM_WIDTH_X8);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400241 mem->dimm_density = fdtdec_get_int(blob, node,
242 "fsp,dimm-density",
Bin Meng497c5162017-05-31 01:04:14 -0700243 DIMM_DENSITY_2GBIT);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400244 mem->dimm_bus_width = fdtdec_get_int(blob, node,
Bin Meng497c5162017-05-31 01:04:14 -0700245 "fsp,dimm-bus-width",
246 DIMM_BUS_WIDTH_64BITS);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400247 mem->dimm_sides = fdtdec_get_int(blob, node,
248 "fsp,dimm-sides",
Bin Meng497c5162017-05-31 01:04:14 -0700249 DIMM_SIDES_1RANKS);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400250 mem->dimm_tcl = fdtdec_get_int(blob, node,
251 "fsp,dimm-tcl", 0x09);
252 mem->dimm_trpt_rcd = fdtdec_get_int(blob, node,
253 "fsp,dimm-trpt-rcd", 0x09);
254 mem->dimm_twr = fdtdec_get_int(blob, node,
Bin Meng497c5162017-05-31 01:04:14 -0700255 "fsp,dimm-twr", 0x0a);
Andrew Bradford74fdb582015-08-07 08:36:35 -0400256 mem->dimm_twtr = fdtdec_get_int(blob, node,
257 "fsp,dimm-twtr", 0x05);
258 mem->dimm_trrd = fdtdec_get_int(blob, node,
259 "fsp,dimm-trrd", 0x04);
260 mem->dimm_trtp = fdtdec_get_int(blob, node,
261 "fsp,dimm-trtp", 0x05);
262 mem->dimm_tfaw = fdtdec_get_int(blob, node,
263 "fsp,dimm-tfaw", 0x14);
264 }
265 }
Simon Glass4a56f102015-01-27 22:13:47 -0700266}