1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 #include <bootsplash.h>
7 #include <console/console.h>
8 #include <cpu/x86/mp.h>
9 #include <device/mmio.h>
10 #include <device/device.h>
11 #include <device/pci.h>
12 #include <device/pci_ops.h>
13 #include <intelblocks/acpi.h>
14 #include <intelblocks/cfg.h>
15 #include <intelblocks/fast_spi.h>
16 #include <intelblocks/msr.h>
17 #include <intelblocks/p2sb.h>
18 #include <intelblocks/power_limit.h>
19 #include <intelblocks/xdci.h>
22 #include <intelblocks/cpulib.h>
23 #include <intelblocks/gpio.h>
24 #include <intelblocks/itss.h>
25 #include <intelblocks/pmclib.h>
28 #include <soc/intel/common/vbt.h>
29 #include <soc/iomap.h>
32 #include <soc/pci_devs.h>
34 #include <soc/systemagent.h>
35 #include <spi-generic.h>
37 #include <soc/ramstage.h>
38 #include <soc/soc_chip.h>
43 #define DUAL_ROLE_CFG0 0x80d8
44 #define SW_VBUS_VALID_MASK (1 << 24)
45 #define SW_IDPIN_EN_MASK (1 << 21)
46 #define SW_IDPIN_MASK (1 << 20)
47 #define SW_IDPIN_HOST (0 << 20)
48 #define DUAL_ROLE_CFG1 0x80dc
49 #define DRD_MODE_MASK (1 << 29)
50 #define DRD_MODE_HOST (1 << 29)
52 #define CFG_XHCLKGTEN 0x8650
53 /* Naking USB2.0 EPs for Backbone Clock Gating and PLL Shutdown */
54 #define NUEFBCGPS (1 << 28)
55 /* SRAM Power Gate Enable */
56 #define SRAMPGTEN (1 << 27)
57 /* SS Link PLL Shutdown Enable */
58 #define SSLSE (1 << 26)
59 /* USB2 PLL Shutdown Enable */
60 #define USB2PLLSE (1 << 25)
61 /* IOSF Sideband Trunk Clock Gating Enable */
62 #define IOSFSTCGE (1 << 24)
63 /* BIT[23:20] HS Backbone PXP Trunk Clock Gate Enable */
64 #define HSTCGE (1 << 23 | 1 << 22)
65 /* BIT[19:16] SS Backbone PXP Trunk Clock Gate Enable */
66 #define SSTCGE (1 << 19 | 1 << 18 | 1 << 17)
68 #define XHCIGEU3S (1 << 15)
69 /* XHC Frame Timer Clock Shutdown Enable */
70 #define XHCFTCLKSE (1 << 14)
71 /* XHC Backbone PXP Trunk Clock Gate In Presence of ISOCH EP */
72 #define XHCBBTCGIPISO (1 << 13)
73 /* XHC HS Backbone PXP Trunk Clock Gate U2 non RWE */
74 #define XHCHSTCGU2NRWE (1 << 12)
75 /* BIT[11:10] XHC USB2 PLL Shutdown Lx Enable */
76 #define XHCUSB2PLLSDLE (1 << 11 | 1 << 10)
77 /* BIT[9:8] HS Backbone PXP PLL Shutdown Ux Enable */
78 #define HSUXDMIPLLSE (1 << 9)
79 /* BIT[7:5] SS Backbone PXP PLL shutdown Ux Enable */
80 #define SSPLLSUE (1 << 6)
81 /* XHC Backbone Local Clock Gating Enable */
82 #define XHCBLCGE (1 << 4)
83 /* HS Link Trunk Clock Gating Enable */
84 #define HSLTCGE (1 << 3)
85 /* SS Link Trunk Clock Gating Enable */
86 #define SSLTCGE (1 << 2)
87 /* IOSF Backbone Trunk Clock Gating Enable */
88 #define IOSFBTCGE (1 << 1)
89 /* IOSF Gasket Backbone Local Clock Gating Enable */
90 #define IOSFGBLCGE (1 << 0)
92 #define CFG_XHCPMCTRL 0x80a4
93 /* BIT[7:4] LFPS periodic sampling for USB3 Ports */
94 #define LFPS_PM_DISABLE_MASK 0xFFFFFF0F
96 const char *soc_acpi_name(const struct device
*dev
)
98 if (dev
->path
.type
== DEVICE_PATH_DOMAIN
)
101 if (dev
->path
.type
== DEVICE_PATH_USB
) {
102 switch (dev
->path
.usb
.port_type
) {
108 switch (dev
->path
.usb
.port_id
) {
109 case 0: return "HS01";
110 case 1: return "HS02";
111 case 2: return "HS03";
112 case 3: return "HS04";
113 case 4: return "HS05";
114 case 5: return "HS06";
115 case 6: return "HS07";
116 case 7: return "HS08";
118 if (CONFIG(SOC_INTEL_GEMINILAKE
))
124 switch (dev
->path
.usb
.port_id
) {
125 case 0: return "SS01";
126 case 1: return "SS02";
127 case 2: return "SS03";
128 case 3: return "SS04";
129 case 4: return "SS05";
130 case 5: return "SS06";
137 if (dev
->path
.type
!= DEVICE_PATH_PCI
)
140 switch (dev
->path
.pci
.devfn
) {
141 /* DSDT: acpi/northbridge.asl */
144 /* DSDT: acpi/xhci.asl */
147 /* DSDT: acpi/pch_hda.asl */
150 /* DSDT: acpi/lpss.asl */
151 case PCH_DEVFN_UART0
:
153 case PCH_DEVFN_UART1
:
155 case PCH_DEVFN_UART2
:
157 case PCH_DEVFN_UART3
:
184 case PCH_DEVFN_SDCARD
:
191 case PCH_DEVFN_PCIE1
:
193 case PCH_DEVFN_PCIE5
:
200 static struct device_operations pci_domain_ops
= {
201 .read_resources
= pci_domain_read_resources
,
202 .set_resources
= pci_domain_set_resources
,
203 .scan_bus
= pci_domain_scan_bus
,
204 .acpi_name
= &soc_acpi_name
,
207 static struct device_operations cpu_bus_ops
= {
208 .read_resources
= noop_read_resources
,
209 .set_resources
= noop_set_resources
,
210 .init
= apollolake_init_cpus
,
211 .acpi_fill_ssdt
= generate_cpu_entries
,
214 static void enable_dev(struct device
*dev
)
216 /* Set the operations if it is a special bus type */
217 if (dev
->path
.type
== DEVICE_PATH_DOMAIN
)
218 dev
->ops
= &pci_domain_ops
;
219 else if (dev
->path
.type
== DEVICE_PATH_CPU_CLUSTER
)
220 dev
->ops
= &cpu_bus_ops
;
221 else if (dev
->path
.type
== DEVICE_PATH_GPIO
)
222 block_gpio_enable(dev
);
226 * If the PCIe root port at function 0 is disabled,
227 * the PCIe root ports might be coalesced after FSP silicon init.
228 * The below function will swap the devfn of the first enabled device
229 * in devicetree and function 0 resides a pci device
230 * so that it won't confuse coreboot.
232 static void pcie_update_device_tree(unsigned int devfn0
, int num_funcs
)
234 struct device
*func0
;
237 unsigned int inc
= PCI_DEVFN(0, 1);
239 func0
= pcidev_path_on_root(devfn0
);
243 /* No more functions if function 0 is disabled. */
244 if (pci_read_config32(func0
, PCI_VENDOR_ID
) == 0xffffffff)
247 devfn
= devfn0
+ inc
;
250 * Increase function by 1.
251 * Then find first enabled device to replace func0
252 * as that port was move to func0.
254 for (i
= 1; i
< num_funcs
; i
++, devfn
+= inc
) {
255 struct device
*dev
= pcidev_path_on_root(devfn
);
261 /* Found the first enabled device in given dev number */
262 func0
->path
.pci
.devfn
= dev
->path
.pci
.devfn
;
263 dev
->path
.pci
.devfn
= devfn0
;
268 static void pcie_override_devicetree_after_silicon_init(void)
270 pcie_update_device_tree(PCH_DEVFN_PCIE1
, 4);
271 pcie_update_device_tree(PCH_DEVFN_PCIE5
, 2);
274 /* Overwrites the SCI IRQ if another IRQ number is given by device tree. */
275 static void set_sci_irq(void)
277 struct soc_intel_apollolake_config
*cfg
;
280 cfg
= config_of_soc();
282 /* Change only if a device tree entry exists. */
284 scis
= soc_read_sci_irq_select();
285 scis
&= ~SCI_IRQ_SEL
;
286 scis
|= (cfg
->sci_irq
<< SCI_IRQ_ADJUST
) & SCI_IRQ_SEL
;
287 soc_write_sci_irq_select(scis
);
291 static void soc_init(void *data
)
293 struct soc_power_limits_config
*soc_config
;
296 /* Snapshot the current GPIO IRQ polarities. FSP is setting a
297 * default policy that doesn't honor boards' requirements. */
298 itss_snapshot_irq_polarities(GPIO_IRQ_START
, GPIO_IRQ_END
);
301 * Clear the GPI interrupt status and enable registers. These
302 * registers do not get reset to default state when booting from S5.
308 /* Restore GPIO IRQ polarities back to previous settings. */
309 itss_restore_irq_polarities(GPIO_IRQ_START
, GPIO_IRQ_END
);
311 /* override 'enabled' setting in device tree if needed */
312 pcie_override_devicetree_after_silicon_init();
315 * Keep the P2SB device visible so it and the other devices are
316 * visible in coreboot for driver support and PCI resource allocation.
317 * There is a UPD setting for this, but it's more consistent to use
318 * hide and unhide symmetrically.
322 if (CONFIG(APL_SKIP_SET_POWER_LIMITS
)) {
323 printk(BIOS_INFO
, "Skip setting RAPL per configuration\n");
325 config
= config_of_soc();
326 /* Set RAPL MSR for Package power limits */
327 soc_config
= &config
->power_limits_config
;
328 set_power_limits(MOBILE_SKU_PL1_TIME_SEC
, soc_config
);
332 * FSP-S routes SCI to IRQ 9. With the help of this function you can
333 * select another IRQ for SCI.
338 static void soc_final(void *data
)
340 /* Make sure payload/OS can't trigger global reset */
341 pmc_global_reset_disable_and_lock();
344 static void disable_dev(struct device
*dev
, FSP_S_CONFIG
*silconfig
)
346 switch (dev
->path
.pci
.devfn
) {
349 * Disable this device in the parse_devicetree_setting() function
354 silconfig
->IshEnable
= 0;
357 silconfig
->EnableSata
= 0;
359 case PCH_DEVFN_PCIE5
:
360 silconfig
->PcieRootPortEn
[0] = 0;
361 silconfig
->PcieRpHotPlug
[0] = 0;
363 case PCH_DEVFN_PCIE6
:
364 silconfig
->PcieRootPortEn
[1] = 0;
365 silconfig
->PcieRpHotPlug
[1] = 0;
367 case PCH_DEVFN_PCIE1
:
368 silconfig
->PcieRootPortEn
[2] = 0;
369 silconfig
->PcieRpHotPlug
[2] = 0;
371 case PCH_DEVFN_PCIE2
:
372 silconfig
->PcieRootPortEn
[3] = 0;
373 silconfig
->PcieRpHotPlug
[3] = 0;
375 case PCH_DEVFN_PCIE3
:
376 silconfig
->PcieRootPortEn
[4] = 0;
377 silconfig
->PcieRpHotPlug
[4] = 0;
379 case PCH_DEVFN_PCIE4
:
380 silconfig
->PcieRootPortEn
[5] = 0;
381 silconfig
->PcieRpHotPlug
[5] = 0;
384 silconfig
->Usb30Mode
= 0;
387 silconfig
->UsbOtg
= 0;
390 silconfig
->I2c0Enable
= 0;
393 silconfig
->I2c1Enable
= 0;
396 silconfig
->I2c2Enable
= 0;
399 silconfig
->I2c3Enable
= 0;
402 silconfig
->I2c4Enable
= 0;
405 silconfig
->I2c5Enable
= 0;
408 silconfig
->I2c6Enable
= 0;
411 silconfig
->I2c7Enable
= 0;
413 case PCH_DEVFN_UART0
:
414 silconfig
->Hsuart0Enable
= 0;
416 case PCH_DEVFN_UART1
:
417 silconfig
->Hsuart1Enable
= 0;
419 case PCH_DEVFN_UART2
:
420 silconfig
->Hsuart2Enable
= 0;
422 case PCH_DEVFN_UART3
:
423 silconfig
->Hsuart3Enable
= 0;
426 silconfig
->Spi0Enable
= 0;
429 silconfig
->Spi1Enable
= 0;
432 silconfig
->Spi2Enable
= 0;
434 case PCH_DEVFN_SDCARD
:
435 silconfig
->SdcardEnabled
= 0;
438 silconfig
->eMMCEnabled
= 0;
441 silconfig
->SdioEnabled
= 0;
443 case PCH_DEVFN_SMBUS
:
444 silconfig
->SmbusEnable
= 0;
446 #if !CONFIG(SOC_INTEL_GEMINILAKE)
448 silconfig
->IpuEn
= 0;
452 silconfig
->HdaEnable
= 0;
455 printk(BIOS_WARNING
, "PCI:%02x.%01x: Could not disable the device\n",
456 PCI_SLOT(dev
->path
.pci
.devfn
),
457 PCI_FUNC(dev
->path
.pci
.devfn
));
462 static void parse_devicetree(FSP_S_CONFIG
*silconfig
)
464 struct device
*dev
= pcidev_path_on_root(SA_DEVFN_ROOT
);
467 printk(BIOS_ERR
, "Could not find root device\n");
470 /* Only disable bus 0 devices. */
471 for (dev
= dev
->bus
->children
; dev
; dev
= dev
->sibling
) {
473 disable_dev(dev
, silconfig
);
477 static void apl_fsp_silicon_init_params_cb(struct soc_intel_apollolake_config
478 *cfg
, FSP_S_CONFIG
*silconfig
)
480 #if !CONFIG(SOC_INTEL_GEMINILAKE) /* GLK FSP does not have these fields in FspsUpd.h yet */
483 for (port
= 0; port
< APOLLOLAKE_USB2_PORT_MAX
; port
++) {
484 if (cfg
->usb_config_override
) {
485 if (!cfg
->usb2_port
[port
].enable
)
488 silconfig
->PortUsb20Enable
[port
] = 1;
489 silconfig
->PortUs20bOverCurrentPin
[port
] = cfg
->usb2_port
[port
].oc_pin
;
492 if (cfg
->usb2eye
[port
].Usb20PerPortTxPeHalf
!= 0)
493 silconfig
->PortUsb20PerPortTxPeHalf
[port
] =
494 cfg
->usb2eye
[port
].Usb20PerPortTxPeHalf
;
496 if (cfg
->usb2eye
[port
].Usb20PerPortPeTxiSet
!= 0)
497 silconfig
->PortUsb20PerPortPeTxiSet
[port
] =
498 cfg
->usb2eye
[port
].Usb20PerPortPeTxiSet
;
500 if (cfg
->usb2eye
[port
].Usb20PerPortTxiSet
!= 0)
501 silconfig
->PortUsb20PerPortTxiSet
[port
] =
502 cfg
->usb2eye
[port
].Usb20PerPortTxiSet
;
504 if (cfg
->usb2eye
[port
].Usb20HsSkewSel
!= 0)
505 silconfig
->PortUsb20HsSkewSel
[port
] =
506 cfg
->usb2eye
[port
].Usb20HsSkewSel
;
508 if (cfg
->usb2eye
[port
].Usb20IUsbTxEmphasisEn
!= 0)
509 silconfig
->PortUsb20IUsbTxEmphasisEn
[port
] =
510 cfg
->usb2eye
[port
].Usb20IUsbTxEmphasisEn
;
512 if (cfg
->usb2eye
[port
].Usb20PerPortRXISet
!= 0)
513 silconfig
->PortUsb20PerPortRXISet
[port
] =
514 cfg
->usb2eye
[port
].Usb20PerPortRXISet
;
516 if (cfg
->usb2eye
[port
].Usb20HsNpreDrvSel
!= 0)
517 silconfig
->PortUsb20HsNpreDrvSel
[port
] =
518 cfg
->usb2eye
[port
].Usb20HsNpreDrvSel
;
521 if (cfg
->usb_config_override
) {
522 for (port
= 0; port
< APOLLOLAKE_USB3_PORT_MAX
; port
++) {
523 if (!cfg
->usb3_port
[port
].enable
)
526 silconfig
->PortUsb30Enable
[port
] = 1;
527 silconfig
->PortUs30bOverCurrentPin
[port
] = cfg
->usb3_port
[port
].oc_pin
;
533 static void glk_fsp_silicon_init_params_cb(
534 struct soc_intel_apollolake_config
*cfg
, FSP_S_CONFIG
*silconfig
)
536 #if CONFIG(SOC_INTEL_GEMINILAKE)
539 for (port
= 0; port
< APOLLOLAKE_USB2_PORT_MAX
; port
++) {
540 if (!cfg
->usb2eye
[port
].Usb20OverrideEn
)
543 silconfig
->Usb2AfePehalfbit
[port
] =
544 cfg
->usb2eye
[port
].Usb20PerPortTxPeHalf
;
545 silconfig
->Usb2AfePetxiset
[port
] =
546 cfg
->usb2eye
[port
].Usb20PerPortPeTxiSet
;
547 silconfig
->Usb2AfeTxiset
[port
] =
548 cfg
->usb2eye
[port
].Usb20PerPortTxiSet
;
549 silconfig
->Usb2AfePredeemp
[port
] =
550 cfg
->usb2eye
[port
].Usb20IUsbTxEmphasisEn
;
553 silconfig
->Gmm
= is_devfn_enabled(SA_GLK_DEVFN_GMM
);
555 /* On Geminilake, we need to override the default FSP PCIe de-emphasis
556 * settings using the device tree settings. This is because PCIe
557 * de-emphasis is enabled by default and Thunderpeak PCIe WiFi detection
558 * requires de-emphasis disabled. If we make this change common to both
559 * Apollolake and Geminilake, then we need to add mainboard device tree
560 * de-emphasis settings of 1 to Apollolake systems.
562 memcpy(silconfig
->PcieRpSelectableDeemphasis
,
563 cfg
->pcie_rp_deemphasis_enable
,
564 sizeof(silconfig
->PcieRpSelectableDeemphasis
));
566 * FSP does not know what the clock requirements are for the
567 * device on SPI bus, hence it should not modify what coreboot
568 * has set up. Hence skipping in FSP.
570 silconfig
->SkipSpiPCP
= 1;
573 * FSP provides UPD interface to execute IPC command. In order to
574 * improve boot performance, configure PmicPmcIpcCtrl for PMC to program
575 * PMIC PCH_PWROK delay.
577 silconfig
->PmicPmcIpcCtrl
= cfg
->PmicPmcIpcCtrl
;
580 * Options to disable XHCI Link Compliance Mode.
582 silconfig
->DisableComplianceMode
= cfg
->DisableComplianceMode
;
585 * Options to change USB3 ModPhy setting for Integrated Filter value.
587 silconfig
->ModPhyIfValue
= cfg
->ModPhyIfValue
;
590 * Options to bump USB3 LDO voltage with 40mv.
592 silconfig
->ModPhyVoltageBump
= cfg
->ModPhyVoltageBump
;
595 * Options to adjust PMIC Vdd2 voltage.
597 silconfig
->PmicVdd2Voltage
= cfg
->PmicVdd2Voltage
;
601 void __weak
mainboard_devtree_update(struct device
*dev
)
603 /* Override dev tree settings per board */
606 void platform_fsp_silicon_init_params_cb(FSPS_UPD
*silupd
)
608 FSP_S_CONFIG
*silconfig
= &silupd
->FspsConfig
;
609 struct soc_intel_apollolake_config
*cfg
;
612 /* Load VBT before devicetree-specific config. */
613 silconfig
->GraphicsConfigPtr
= (uintptr_t)vbt_get();
615 dev
= pcidev_path_on_root(SA_DEVFN_ROOT
);
616 cfg
= config_of(dev
);
618 mainboard_devtree_update(dev
);
620 /* Parse device tree and disable unused device*/
621 parse_devicetree(silconfig
);
623 memcpy(silconfig
->PcieRpClkReqNumber
, cfg
->pcie_rp_clkreq_pin
,
624 sizeof(silconfig
->PcieRpClkReqNumber
));
626 memcpy(silconfig
->PcieRpHotPlug
, cfg
->pcie_rp_hotplug_enable
,
627 sizeof(silconfig
->PcieRpHotPlug
));
629 switch (cfg
->serirq_mode
) {
631 silconfig
->SirqEnable
= 1;
632 silconfig
->SirqMode
= 0;
634 case SERIRQ_CONTINUOUS
:
635 silconfig
->SirqEnable
= 1;
636 silconfig
->SirqMode
= 1;
640 silconfig
->SirqEnable
= 0;
644 if (cfg
->emmc_tx_cmd_cntl
!= 0)
645 silconfig
->EmmcTxCmdCntl
= cfg
->emmc_tx_cmd_cntl
;
646 if (cfg
->emmc_tx_data_cntl1
!= 0)
647 silconfig
->EmmcTxDataCntl1
= cfg
->emmc_tx_data_cntl1
;
648 if (cfg
->emmc_tx_data_cntl2
!= 0)
649 silconfig
->EmmcTxDataCntl2
= cfg
->emmc_tx_data_cntl2
;
650 if (cfg
->emmc_rx_cmd_data_cntl1
!= 0)
651 silconfig
->EmmcRxCmdDataCntl1
= cfg
->emmc_rx_cmd_data_cntl1
;
652 if (cfg
->emmc_rx_strobe_cntl
!= 0)
653 silconfig
->EmmcRxStrobeCntl
= cfg
->emmc_rx_strobe_cntl
;
654 if (cfg
->emmc_rx_cmd_data_cntl2
!= 0)
655 silconfig
->EmmcRxCmdDataCntl2
= cfg
->emmc_rx_cmd_data_cntl2
;
656 if (cfg
->emmc_host_max_speed
!= 0)
657 silconfig
->eMMCHostMaxSpeed
= cfg
->emmc_host_max_speed
;
659 silconfig
->LPSS_S0ixEnable
= cfg
->lpss_s0ix_enable
;
661 /* Disable monitor mwait since it is broken due to a hardware bug
662 * without a fix. Specific to Apollolake.
664 if (!CONFIG(SOC_INTEL_GEMINILAKE
))
665 silconfig
->MonitorMwaitEnable
= 0;
667 silconfig
->SkipMpInit
= !CONFIG(USE_INTEL_FSP_MP_INIT
);
669 /* Disable setting of EISS bit in FSP. */
670 silconfig
->SpiEiss
= 0;
672 /* Disable FSP from locking access to the RTC NVRAM */
673 silconfig
->RtcLock
= 0;
675 /* Enable Audio clk gate and power gate */
676 silconfig
->HDAudioClkGate
= cfg
->hdaudio_clk_gate_enable
;
677 silconfig
->HDAudioPwrGate
= cfg
->hdaudio_pwr_gate_enable
;
678 /* BIOS config lockdown Audio clk and power gate */
679 silconfig
->BiosCfgLockDown
= cfg
->hdaudio_bios_config_lockdown
;
680 if (CONFIG(SOC_INTEL_GEMINILAKE
))
681 glk_fsp_silicon_init_params_cb(cfg
, silconfig
);
683 apl_fsp_silicon_init_params_cb(cfg
, silconfig
);
685 silconfig
->UsbOtg
= xdci_can_enable(PCH_DEVFN_XDCI
);
687 silconfig
->VmxEnable
= CONFIG(ENABLE_VMX
);
689 /* Set VTD feature according to devicetree */
690 silconfig
->VtdEnable
= cfg
->enable_vtd
;
692 silconfig
->PeiGraphicsPeimInit
= CONFIG(RUN_FSP_GOP
) && is_devfn_enabled(SA_DEVFN_IGD
);
694 silconfig
->PavpEnable
= CONFIG(PAVP
);
696 mainboard_silicon_init_params(silconfig
);
699 struct chip_operations soc_intel_apollolake_ops
= {
700 CHIP_NAME("Intel Apollolake SOC")
701 .enable_dev
= &enable_dev
,
706 static void soc_enable_untrusted_mode(void *unused
)
709 * Set Bit 6 (ENABLE_IA_UNTRUSTED_MODE) of MSR 0x120
710 * UCODE_PCR_POWER_MISC MSR to enter IA Untrusted Mode.
712 msr_set(MSR_POWER_MISC
, ENABLE_IA_UNTRUSTED
);
715 static void drop_privilege_all(void)
717 /* Drop privilege level on all the CPUs */
718 if (mp_run_on_all_cpus(&soc_enable_untrusted_mode
, NULL
) != CB_SUCCESS
)
719 printk(BIOS_ERR
, "failed to enable untrusted mode\n");
722 static void configure_xhci_host_mode_port0(void)
726 const struct resource
*res
;
729 struct device
*xhci_dev
= PCH_DEV_XHCI
;
731 printk(BIOS_INFO
, "Putting xHCI port 0 into host mode.\n");
732 res
= find_resource(xhci_dev
, PCI_BASE_ADDRESS_0
);
733 cfg0
= (void *)(uintptr_t)(res
->base
+ DUAL_ROLE_CFG0
);
734 cfg1
= (void *)(uintptr_t)(res
->base
+ DUAL_ROLE_CFG1
);
736 if (!(reg
& SW_IDPIN_EN_MASK
))
739 reg
&= ~(SW_IDPIN_MASK
| SW_VBUS_VALID_MASK
);
742 stopwatch_init_msecs_expire(&sw
, 10);
743 /* Wait for the host mode status bit. */
744 while ((read32(cfg1
) & DRD_MODE_MASK
) != DRD_MODE_HOST
) {
745 if (stopwatch_expired(&sw
)) {
746 printk(BIOS_ERR
, "Timed out waiting for host mode.\n");
751 printk(BIOS_INFO
, "xHCI port 0 host switch over took %lu ms\n",
752 stopwatch_duration_msecs(&sw
));
755 static int check_xdci_enable(void)
757 return is_dev_enabled(pcidev_path_on_root(PCH_DEVFN_XDCI
));
760 static void disable_xhci_lfps_pm(void)
762 struct soc_intel_apollolake_config
*cfg
;
764 cfg
= config_of_soc();
766 if (cfg
->disable_xhci_lfps_pm
) {
768 const struct resource
*res
;
770 struct device
*xhci_dev
= PCH_DEV_XHCI
;
772 res
= find_resource(xhci_dev
, PCI_BASE_ADDRESS_0
);
773 addr
= (void *)(uintptr_t)(res
->base
+ CFG_XHCPMCTRL
);
775 printk(BIOS_DEBUG
, "XHCI PM: control reg=0x%x.\n", reg
);
777 reg
&= LFPS_PM_DISABLE_MASK
;
779 printk(BIOS_INFO
, "XHCI PM: Disable xHCI LFPS as configured in devicetree.\n");
784 void platform_fsp_notify_status(enum fsp_notify_phase phase
)
786 if (phase
== END_OF_FIRMWARE
) {
789 * Before hiding P2SB device and dropping privilege level,
790 * dump CSE status and disable HECI1 interface.
794 /* Hide the P2SB device to align with previous behavior. */
798 * As per guidelines BIOS is recommended to drop CPU privilege
799 * level to IA_UNTRUSTED. After that certain device registers
800 * and MSRs become inaccessible supposedly increasing system
803 drop_privilege_all();
806 * When USB OTG is set, GLK FSP enables xHCI SW ID pin and
807 * configures USB-C as device mode. Force USB-C into host mode.
809 if (check_xdci_enable())
810 configure_xhci_host_mode_port0();
813 * Override GLK xhci clock gating register(XHCLKGTEN) to
814 * mitigate USB device suspend and resume failure.
816 if (CONFIG(SOC_INTEL_GEMINILAKE
)) {
818 const struct resource
*res
;
820 struct device
*xhci_dev
= PCH_DEV_XHCI
;
822 res
= find_resource(xhci_dev
, PCI_BASE_ADDRESS_0
);
823 cfg
= (void *)(uintptr_t)(res
->base
+ CFG_XHCLKGTEN
);
824 reg
= SRAMPGTEN
| SSLSE
| USB2PLLSE
| IOSFSTCGE
|
825 HSTCGE
| HSUXDMIPLLSE
| SSTCGE
| XHCFTCLKSE
|
826 XHCBBTCGIPISO
| XHCUSB2PLLSDLE
| SSPLLSUE
|
827 XHCBLCGE
| HSLTCGE
| SSLTCGE
| IOSFBTCGE
|
832 /* Disable XHCI LFPS power management if the option in dev tree is set. */
833 disable_xhci_lfps_pm();
838 * spi_flash init() needs to run unconditionally on every boot (including
839 * resume) to allow write protect to be disabled for eventlog and nvram
840 * updates. This needs to be done as early as possible in ramstage. Thus, add a
841 * callback for entry into BS_PRE_DEVICE.
843 static void spi_flash_init_cb(void *unused
)
849 void mainboard_silicon_init_params(FSP_S_CONFIG
*silconfig
)
851 printk(BIOS_DEBUG
, "WEAK: %s/%s called\n", __FILE__
, __func__
);
854 /* Handle FSP logo params */
855 void soc_load_logo(FSPS_UPD
*supd
)
857 bmp_load_logo(&supd
->FspsConfig
.LogoPtr
, &supd
->FspsConfig
.LogoSize
);
860 BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE
, BS_ON_ENTRY
, spi_flash_init_cb
, NULL
);