2 Lib function for Pei QNC.
4 Copyright (c) 2013-2015 Intel Corporation.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "CommonHeader.h"
12 This function provides the necessary SOC initialization
13 before MRC running. It sets RCBA, GPIO, PMBASE
14 and some parts of SOC through SOC message method.
15 If the function cannot complete it'll ASSERT().
25 // QNCPortWrite(Port#, Offset, Value)
28 // Set the fixed PRI Status encodings config.
31 QUARK_NC_MEMORY_ARBITER_SB_PORT_ID
,
32 QUARK_NC_MEMORY_ARBITER_REG_ASTATUS
,
33 QNC_FIXED_CONFIG_ASTATUS
36 // Sideband register write to Remote Management Unit
37 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QNC_MSG_TMPM_REG_PMBA
, (BIT31
| PcdGet16 (PcdPmbaIoBaseAddress
)));
39 // Configurable I/O address in iLB (legacy block)
41 LpcPciCfg32 (R_QNC_LPC_SMBUS_BASE
) = BIT31
| PcdGet16 (PcdSmbaIoBaseAddress
);
42 LpcPciCfg32 (R_QNC_LPC_GBA_BASE
) = BIT31
| PcdGet16 (PcdGbaIoBaseAddress
);
43 LpcPciCfg32 (R_QNC_LPC_PM1BLK
) = BIT31
| PcdGet16 (PcdPm1blkIoBaseAddress
);
44 LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) = BIT31
| PcdGet16 (PcdGpe0blkIoBaseAddress
);
45 LpcPciCfg32 (R_QNC_LPC_WDTBA
) = BIT31
| PcdGet16 (PcdWdtbaIoBaseAddress
);
48 // Program RCBA Base Address
50 LpcPciCfg32AndThenOr (R_QNC_LPC_RCBA
, (~B_QNC_LPC_RCBA_MASK
), (((UINT32
)(PcdGet64 (PcdRcbaMmioBaseAddress
))) | B_QNC_LPC_RCBA_EN
));
53 // Program Memory Manager fixed config values.
56 RegValue
= QNCPortRead (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID
, QUARK_NC_MEMORY_MANAGER_BTHCTRL
);
57 RegValue
&= ~(DRAM_NON_HOST_RQ_LIMIT_MASK
);
58 RegValue
|= (V_DRAM_NON_HOST_RQ_LIMIT
<< DRAM_NON_HOST_RQ_LIMIT_BP
);
59 QNCPortWrite (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID
, QUARK_NC_MEMORY_MANAGER_BTHCTRL
, RegValue
);
62 // Program iCLK fixed config values.
66 (UINT32
) ~(B_MUXTOP_FLEX2_MASK
| B_MUXTOP_FLEX1_MASK
),
67 (V_MUXTOP_FLEX2
<< B_MUXTOP_FLEX2_BP
) | (V_MUXTOP_FLEX1
<< B_MUXTOP_FLEX1_BP
)
70 QUARK_ICLK_REF2_DBUFF0
,
71 (UINT32
) ~(BIT0
), // bit[0] cleared
88 // Set RMU DMA disable bit post boot.
90 RegValue
= QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_OPTIONS_1
);
91 RegValue
|= OPTIONS_1_DMA_DISABLE
;
92 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_OPTIONS_1
, RegValue
);
96 Do north cluster init which needs to be done AFTER MRC init.
110 // Program SVID/SID the same as VID/DID for all devices except root ports.
112 QNCMmPci32(0, MC_BUS
, MC_DEV
, MC_FUN
, R_EFI_PCI_SVID
) = QNCMmPci32(0, MC_BUS
, MC_DEV
, MC_FUN
, PCI_VENDOR_ID_OFFSET
);
113 QNCMmPci32(0, PCI_BUS_NUMBER_QNC
, PCI_DEVICE_NUMBER_QNC_LPC
, PCI_FUNCTION_NUMBER_QNC_LPC
, R_EFI_PCI_SVID
) = QNCMmPci32(0, PCI_BUS_NUMBER_QNC
, PCI_DEVICE_NUMBER_QNC_LPC
, PCI_FUNCTION_NUMBER_QNC_LPC
, PCI_VENDOR_ID_OFFSET
);
114 QNCMmPci32(0, PCI_BUS_NUMBER_QNC
, PCI_DEVICE_NUMBER_QNC_IOSF2AHB_0
, PCI_FUNCTION_NUMBER_QNC_IOSF2AHB
, R_EFI_PCI_SVID
) = QNCMmPci32(0, PCI_BUS_NUMBER_QNC
, PCI_DEVICE_NUMBER_QNC_IOSF2AHB_0
, PCI_FUNCTION_NUMBER_QNC_IOSF2AHB
, PCI_VENDOR_ID_OFFSET
);
115 QNCMmPci32(0, PCI_BUS_NUMBER_QNC
, PCI_DEVICE_NUMBER_QNC_IOSF2AHB_1
, PCI_FUNCTION_NUMBER_QNC_IOSF2AHB
, R_EFI_PCI_SVID
) = QNCMmPci32(0, PCI_BUS_NUMBER_QNC
, PCI_DEVICE_NUMBER_QNC_IOSF2AHB_1
, PCI_FUNCTION_NUMBER_QNC_IOSF2AHB
, PCI_VENDOR_ID_OFFSET
);
120 Used to check QNC if it's S3 state. Clear the register state after query.
122 @retval TRUE if it's S3 state.
123 @retval FALSE if it's not S3 state.
128 QNCCheckS3AndClearState (
132 BOOLEAN S3WakeEventFound
;
141 S3WakeEventFound
= FALSE
;
145 // Read the ACPI registers,
147 Pm1Sts
= IoRead16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1S
);
148 Pm1En
= IoRead16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1E
);
149 Pm1Cnt
= IoRead16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
);
150 Gpe0Sts
= IoRead32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_GPE0S
);
151 Gpe0En
= IoRead32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_GPE0E
);
154 // Clear Power Management 1 Enable Register and
155 // General Purpost Event 0 Enables Register
157 IoWrite16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1E
, 0);
158 IoWrite32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_GPE0E
, 0);
160 if ((Pm1Sts
& B_QNC_PM1BLK_PM1S_WAKE
) != 0 && (Pm1Cnt
& B_QNC_PM1BLK_PM1C_SLPTP
) == V_S3
) {
163 // Detect the actual WAKE event
165 if ((Pm1Sts
& B_QNC_PM1BLK_PM1S_RTC
) && (Pm1En
& B_QNC_PM1BLK_PM1E_RTC
)) {
166 EventDescStr
= "RTC Alarm";
167 S3WakeEventFound
= TRUE
;
169 if ((Pm1Sts
& B_QNC_PM1BLK_PM1S_PCIEWSTS
) && !(Pm1En
& B_QNC_PM1BLK_PM1E_PWAKED
)) {
170 EventDescStr
= "PCIe WAKE";
171 S3WakeEventFound
= TRUE
;
173 if ((Gpe0Sts
& B_QNC_GPE0BLK_GPE0S_PCIE
) && (Gpe0En
& B_QNC_GPE0BLK_GPE0E_PCIE
)) {
174 EventDescStr
= "PCIe";
175 S3WakeEventFound
= TRUE
;
177 if ((Gpe0Sts
& B_QNC_GPE0BLK_GPE0S_GPIO
) && (Gpe0En
& B_QNC_GPE0BLK_GPE0E_GPIO
)) {
178 EventDescStr
= "GPIO";
179 S3WakeEventFound
= TRUE
;
181 if ((Gpe0Sts
& B_QNC_GPE0BLK_GPE0S_EGPE
) && (Gpe0En
& B_QNC_GPE0BLK_GPE0E_EGPE
)) {
182 EventDescStr
= "Ext. GPE";
183 S3WakeEventFound
= TRUE
;
185 if (S3WakeEventFound
== FALSE
) {
186 EventDescStr
= "Unknown";
188 DEBUG ((EFI_D_INFO
, "S3 Wake Event - %a\n", EventDescStr
));
191 // If no Power Button Override event occurs and one enabled wake event occurs,
192 // just do S3 resume and clear the state.
194 IoWrite16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
, (Pm1Cnt
& (~B_QNC_PM1BLK_PM1C_SLPTP
)));
197 // Set EOS to de Assert SMI
199 IoWrite32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_SMIS
, B_QNC_GPE0BLK_SMIS_EOS
);
202 // Enable SMI globally
204 NewValue
= QNCPortRead (QUARK_NC_HOST_BRIDGE_SB_PORT_ID
, QNC_MSG_FSBIC_REG_HMISC
);
206 QNCPortWrite (QUARK_NC_HOST_BRIDGE_SB_PORT_ID
, QNC_MSG_FSBIC_REG_HMISC
, NewValue
);
215 Used to check QNC if system wakes up from power on reset. Clear the register state after query.
217 @retval TRUE if system wakes up from power on reset
218 @retval FALSE if system does not wake up from power on reset
223 QNCCheckPowerOnResetAndClearState (
231 // Read the ACPI registers,
232 // PM1_STS information cannot be lost after power down, unless CMOS is cleared.
234 Pm1Sts
= IoRead16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1S
);
235 Pm1Cnt
= IoRead16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
);
238 // If B_SLP_TYP is S5
240 if ((Pm1Sts
& B_QNC_PM1BLK_PM1S_WAKE
) != 0 && (Pm1Cnt
& B_QNC_PM1BLK_PM1C_SLPTP
) == V_S5
) {
241 IoWrite16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
, (Pm1Cnt
& (~B_QNC_PM1BLK_PM1C_SLPTP
)));
249 This function is used to clear SMI and wake status.
262 // Read the ACPI registers
264 Gpe0Sts
= IoRead32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_GPE0S
);
265 SmiSts
= IoRead32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_SMIS
);
268 // Clear any SMI or wake state from the boot
270 Gpe0Sts
|= B_QNC_GPE0BLK_GPE0S_ALL
;
271 SmiSts
|= B_QNC_GPE0BLK_SMIS_ALL
;
276 IoWrite32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_GPE0S
, Gpe0Sts
);
277 IoWrite32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_SMIS
, SmiSts
);
280 /** Send DRAM Ready opcode.
282 @param[in] OpcodeParam Parameter to DRAM ready opcode.
288 QNCSendOpcodeDramReady (
289 IN UINT32 OpcodeParam
294 // Before sending DRAM ready place invalid value in Scrub Config.
297 QUARK_NC_RMU_SB_PORT_ID
,
298 QUARK_NC_ECC_SCRUB_CONFIG_REG
,
303 // Send opcode and use param to notify HW of new RMU firmware location.
305 McD0PciCfg32 (QNC_ACCESS_PORT_MDR
) = OpcodeParam
;
306 McD0PciCfg32 (QNC_ACCESS_PORT_MCR
) = MESSAGE_SHADOW_DW (QUARK_NC_RMU_SB_PORT_ID
, 0);
309 // HW completed tasks on DRAM ready when scrub config read back as zero.
311 while (QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_ECC_SCRUB_CONFIG_REG
) != 0) {
312 MicroSecondDelay (10);
318 Relocate RMU Main binary to memory after MRC to improve performance.
320 @param[in] DestBaseAddress - Specify the new memory address for the RMU Main binary.
321 @param[in] SrcBaseAddress - Specify the current memory address for the RMU Main binary.
322 @param[in] Size - Specify size of the RMU Main binary.
330 IN CONST UINT32 DestBaseAddress
,
331 IN CONST UINT32 SrcBaseAddress
,
336 // Shadow RMU Main binary into main memory.
338 CopyMem ((VOID
*)(UINTN
)DestBaseAddress
,(VOID
*)(UINTN
) SrcBaseAddress
, Size
);
343 Get the total memory size
348 QNCGetTotalMemorysize (
352 return QNCPortRead(QUARK_NC_HOST_BRIDGE_SB_PORT_ID
, QUARK_NC_HOST_BRIDGE_HMBOUND_REG
) & HMBOUND_MASK
;
357 Get the memory range of TSEG.
358 The TSEG's memory is below TOLM.
360 @param[out] BaseAddress The base address of TSEG's memory range
361 @param[out] MemorySize The size of TSEG's memory range
366 QNCGetTSEGMemoryRange (
367 OUT UINT64
*BaseAddress
,
368 OUT UINT64
*MemorySize
372 UINT64 SMMAddress
= 0;
374 Register
= QncHsmmcRead ();
377 // Get the SMRAM Base address
379 SMMAddress
= Register
& SMM_START_MASK
;
380 *BaseAddress
= LShift16 (SMMAddress
);
383 // Get the SMRAM size
385 SMMAddress
= ((Register
& SMM_END_MASK
) | (~SMM_END_MASK
)) + 1;
386 *MemorySize
= SMMAddress
- (*BaseAddress
);
390 "TSEG's memory range: BaseAddress = 0x%x, Size = 0x%x\n",
391 (UINT32
)*BaseAddress
,
397 Updates the PAM registers in the MCH for the requested range and mode.
399 @param Start The start address of the memory region
400 @param Length The length, in bytes, of the memory region
401 @param ReadEnable Pointer to the boolean variable on whether to enable read for legacy memory section.
402 If NULL, then read attribute will not be touched by this call.
403 @param ReadEnable Pointer to the boolean variable on whether to enable write for legacy memory section.
404 If NULL, then write attribute will not be touched by this call.
405 @param Granularity A pointer to granularity, in bytes, that the PAM registers support
407 @retval RETURN_SUCCESS The PAM registers in the MCH were updated
408 @retval RETURN_INVALID_PARAMETER The memory range is not valid in legacy region.
413 QNCLegacyRegionManipulation (
416 IN BOOLEAN
*ReadEnable
,
417 IN BOOLEAN
*WriteEnable
,
418 OUT UINT32
*Granularity
422 // Do nothing cos no such support on QNC
424 return RETURN_SUCCESS
;
428 Determine if QNC is supported.
430 @retval FALSE QNC is not supported.
431 @retval TRUE QNC is supported.
442 SocVendorId
= MmioRead16 (
443 PciDeviceMmBase (MC_BUS
,
445 MC_FUN
) + PCI_VENDOR_ID_OFFSET
448 SocDeviceId
= QncGetSocDeviceId();
451 // Verify that this is a supported chipset
453 if ((SocVendorId
!= QUARK_MC_VENDOR_ID
) || ((SocDeviceId
!= QUARK_MC_DEVICE_ID
) && (SocDeviceId
!= QUARK2_MC_DEVICE_ID
))) {
454 DEBUG ((DEBUG_ERROR
, "QNC code doesn't support the Soc VendorId:0x%04x Soc DeviceId:0x%04x!\n", SocVendorId
, SocDeviceId
));
461 Get the DeviceId of the SoC
463 @retval PCI DeviceId of the SoC
473 SocDeviceId
= MmioRead16 (
478 ) + PCI_DEVICE_ID_OFFSET
485 Enable SMI detection of legacy flash access violations.
489 QncEnableLegacyFlashAccessViolationSmi (
495 BcValue
= LpcPciCfg32 (R_QNC_LPC_BIOS_CNTL
);
498 // Clear BIOSWE & set BLE.
500 BcValue
&= (~B_QNC_LPC_BIOS_CNTL_BIOSWE
);
501 BcValue
|= (B_QNC_LPC_BIOS_CNTL_BLE
);
503 LpcPciCfg32 (R_QNC_LPC_BIOS_CNTL
) = BcValue
;
505 DEBUG ((EFI_D_INFO
, "BIOS Control Lock Enabled!\n"));
509 Setup RMU Thermal sensor registers for Vref mode.
513 QNCThermalSensorSetVRefMode (
519 UINT32 Tscgf2Config2
;
521 Tscgf1Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF1_CONFIG
);
522 Tscgf2Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG
);
523 Tscgf2Config2
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG2
);
525 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_ISNSCURRENTSEL_MASK
);
526 Tscgf1Config
|= (V_TSCGF1_CONFIG_ISNSCURRENTSEL_VREF_MODE
<< B_TSCGF1_CONFIG_ISNSCURRENTSEL_BP
);
528 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_IBGEN
);
529 Tscgf1Config
|= (V_TSCGF1_CONFIG_IBGEN_VREF_MODE
<< B_TSCGF1_CONFIG_IBGEN_BP
);
531 Tscgf2Config2
&= ~(B_TSCGF2_CONFIG2_ISPARECTRL_MASK
);
532 Tscgf2Config2
|= (V_TSCGF2_CONFIG2_ISPARECTRL_VREF_MODE
<< B_TSCGF2_CONFIG2_ISPARECTRL_BP
);
534 Tscgf2Config2
&= ~(B_TSCGF2_CONFIG2_ICALCOARSETUNE_MASK
);
535 Tscgf2Config2
|= (V_TSCGF2_CONFIG2_ICALCOARSETUNE_VREF_MODE
<< B_TSCGF2_CONFIG2_ICALCOARSETUNE_BP
);
537 Tscgf2Config
&= ~(B_TSCGF2_CONFIG_IDSCONTROL_MASK
);
538 Tscgf2Config
|= (V_TSCGF2_CONFIG_IDSCONTROL_VREF_MODE
<< B_TSCGF2_CONFIG_IDSCONTROL_BP
);
540 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF1_CONFIG
, Tscgf1Config
);
541 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG
, Tscgf2Config
);
542 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG2
, Tscgf2Config2
);
546 Setup RMU Thermal sensor registers for Ratiometric mode.
550 QNCThermalSensorSetRatiometricMode (
556 UINT32 Tscgf2Config2
;
559 Tscgf1Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF1_CONFIG
);
560 Tscgf2Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG
);
561 Tscgf2Config2
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG2
);
562 Tscgf3Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF3_CONFIG
);
564 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_ISNSCURRENTSEL_MASK
);
565 Tscgf1Config
|= (V_TSCGF1_CONFIG_ISNSCURRENTSEL_RATIO_MODE
<< B_TSCGF1_CONFIG_ISNSCURRENTSEL_BP
);
567 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_ISNSCHOPSEL_MASK
);
568 Tscgf1Config
|= (V_TSCGF1_CONFIG_ISNSCHOPSEL_RATIO_MODE
<< B_TSCGF1_CONFIG_ISNSCHOPSEL_BP
);
570 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_ISNSINTERNALVREFEN
);
571 Tscgf1Config
|= (V_TSCGF1_CONFIG_ISNSINTERNALVREFEN_RATIO_MODE
<< B_TSCGF1_CONFIG_ISNSINTERNALVREFEN_BP
);
573 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_IBGEN
);
574 Tscgf1Config
|= (V_TSCGF1_CONFIG_IBGEN_RATIO_MODE
<< B_TSCGF1_CONFIG_IBGEN_BP
);
576 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_IBGCHOPEN
);
577 Tscgf1Config
|= (V_TSCGF1_CONFIG_IBGCHOPEN_RATIO_MODE
<< B_TSCGF1_CONFIG_IBGCHOPEN_BP
);
579 Tscgf2Config2
&= ~(B_TSCGF2_CONFIG2_ICALCONFIGSEL_MASK
);
580 Tscgf2Config2
|= (V_TSCGF2_CONFIG2_ICALCONFIGSEL_RATIO_MODE
<< B_TSCGF2_CONFIG2_ICALCONFIGSEL_BP
);
582 Tscgf2Config2
&= ~(B_TSCGF2_CONFIG2_ISPARECTRL_MASK
);
583 Tscgf2Config2
|= (V_TSCGF2_CONFIG2_ISPARECTRL_RATIO_MODE
<< B_TSCGF2_CONFIG2_ISPARECTRL_BP
);
585 Tscgf2Config2
&= ~(B_TSCGF2_CONFIG2_ICALCOARSETUNE_MASK
);
586 Tscgf2Config2
|= (V_TSCGF2_CONFIG2_ICALCOARSETUNE_RATIO_MODE
<< B_TSCGF2_CONFIG2_ICALCOARSETUNE_BP
);
588 Tscgf2Config
&= ~(B_TSCGF2_CONFIG_IDSCONTROL_MASK
);
589 Tscgf2Config
|= (V_TSCGF2_CONFIG_IDSCONTROL_RATIO_MODE
<< B_TSCGF2_CONFIG_IDSCONTROL_BP
);
591 Tscgf2Config
&= ~(B_TSCGF2_CONFIG_IDSTIMING_MASK
);
592 Tscgf2Config
|= (V_TSCGF2_CONFIG_IDSTIMING_RATIO_MODE
<< B_TSCGF2_CONFIG_IDSTIMING_BP
);
594 Tscgf3Config
&= ~(B_TSCGF3_CONFIG_ITSGAMMACOEFF_MASK
);
595 Tscgf3Config
|= (V_TSCGF3_CONFIG_ITSGAMMACOEFF_RATIO_MODE
<< B_TSCGF3_CONFIG_ITSGAMMACOEFF_BP
);
597 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF1_CONFIG
, Tscgf1Config
);
598 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG
, Tscgf2Config
);
599 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG2
, Tscgf2Config2
);
600 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF3_CONFIG
, Tscgf3Config
);
604 Setup RMU Thermal sensor trip point values.
606 @param[in] CatastrophicTripOnDegreesCelsius - Catastrophic set trip point threshold.
607 @param[in] HotTripOnDegreesCelsius - Hot set trip point threshold.
608 @param[in] HotTripOffDegreesCelsius - Hot clear trip point threshold.
610 @retval EFI_SUCCESS Trip points setup.
611 @retval EFI_INVALID_PARAMETER Invalid trip point value.
616 QNCThermalSensorSetTripValues (
617 IN CONST UINTN CatastrophicTripOnDegreesCelsius
,
618 IN CONST UINTN HotTripOnDegreesCelsius
,
619 IN CONST UINTN HotTripOffDegreesCelsius
622 UINT32 RegisterValue
;
625 // Register fields are 8-bit temperature values of granularity 1 degree C
626 // where 0x00 corresponds to -50 degrees C
627 // and 0xFF corresponds to 205 degrees C.
629 // User passes unsigned values in degrees Celsius so trips < 0 not supported.
631 // Add 50 to user values to get values for register fields.
634 if ((CatastrophicTripOnDegreesCelsius
> 205) || (HotTripOnDegreesCelsius
> 205) || (HotTripOffDegreesCelsius
> 205)) {
635 return EFI_INVALID_PARAMETER
;
642 ((0 + 50) << TS_CAT_TRIP_CLEAR_THOLD_BP
) | // Cat Trip Clear value must be less than Cat Trip Set Value.
643 ((CatastrophicTripOnDegreesCelsius
+ 50) << TS_CAT_TRIP_SET_THOLD_BP
) |
644 ((HotTripOnDegreesCelsius
+ 50) << TS_HOT_TRIP_SET_THOLD_BP
) |
645 ((HotTripOffDegreesCelsius
+ 50) << TS_HOT_TRIP_CLEAR_THOLD_BP
)
648 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_TS_TRIP
, RegisterValue
);
654 Enable RMU Thermal sensor with a Catastrophic Trip point.
656 @retval EFI_SUCCESS Trip points setup.
657 @retval EFI_INVALID_PARAMETER Invalid trip point value.
662 QNCThermalSensorEnableWithCatastrophicTrip (
663 IN CONST UINTN CatastrophicTripOnDegreesCelsius
671 // Trip Register fields are 8-bit temperature values of granularity 1 degree C
672 // where 0x00 corresponds to -50 degrees C
673 // and 0xFF corresponds to 205 degrees C.
675 // User passes unsigned values in degrees Celsius so trips < 0 not supported.
677 // Add 50 to user values to get values for register fields.
680 if (CatastrophicTripOnDegreesCelsius
> 205) {
681 return EFI_INVALID_PARAMETER
;
684 Tscgf3Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF3_CONFIG
);
685 TsModeReg
= QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_TS_MODE
);
686 TsTripReg
= QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_TS_TRIP
);
689 // Setup Catastrophic Trip point.
691 TsTripReg
&= ~(TS_CAT_TRIP_SET_THOLD_MASK
);
692 TsTripReg
|= ((CatastrophicTripOnDegreesCelsius
+ 50) << TS_CAT_TRIP_SET_THOLD_BP
);
693 TsTripReg
&= ~(TS_CAT_TRIP_CLEAR_THOLD_MASK
);
694 TsTripReg
|= ((0 + 50) << TS_CAT_TRIP_CLEAR_THOLD_BP
); // Cat Trip Clear value must be less than Cat Trip Set Value.
695 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_TS_TRIP
, TsTripReg
);
698 // To enable the TS do the following:
699 // 1) Take the TS out of reset by setting itsrst to 0x0.
700 // 2) Enable the TS using RMU Thermal sensor mode register.
703 Tscgf3Config
&= ~(B_TSCGF3_CONFIG_ITSRST
);
704 TsModeReg
|= TS_ENABLE
;
706 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF3_CONFIG
, Tscgf3Config
);
707 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_TS_MODE
, TsModeReg
);
713 Lock all RMU Thermal sensor control & trip point registers.
718 QNCThermalSensorLockAllRegisters (
725 LockMask
= TS_LOCK_THRM_CTRL_REGS_ENABLE
| TS_LOCK_AUX_TRIP_PT_REGS_ENABLE
;
727 RegValue
= QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_CONFIG
);
728 RegValue
|= LockMask
;
729 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_CONFIG
, RegValue
);
731 ASSERT ((LockMask
== (QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_CONFIG
) & LockMask
)));
735 Set chipset policy for double bit ECC error.
737 @param[in] PolicyValue Policy to config on double bit ECC error.
742 QNCPolicyDblEccBitErr (
743 IN CONST UINT32 PolicyValue
747 Register
= QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_WDT_CONTROL
);
748 Register
&= ~(B_WDT_CONTROL_DBL_ECC_BIT_ERR_MASK
);
749 Register
|= PolicyValue
;
751 QUARK_NC_RMU_SB_PORT_ID
,
752 QUARK_NC_RMU_REG_WDT_CONTROL
,
758 Determine if running on secure Quark hardware Sku.
760 @retval FALSE Base Quark Sku or unprovisioned Secure Sku running.
761 @retval TRUE Provisioned SecureSku hardware running.
765 QncIsSecureProvisionedSku (
769 // Read QUARK Secure SKU Fuse
770 return ((QNCAltPortRead (QUARK_SCSS_FUSE_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_SPI_ROM_FUSE
) & BIT6
) == BIT6
);