2 Lib function for Pei QNC.
4 Copyright (c) 2013-2015 Intel Corporation.
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "CommonHeader.h"
18 This function provides the necessary SOC initialization
19 before MRC running. It sets RCBA, GPIO, PMBASE
20 and some parts of SOC through SOC message method.
21 If the function cannot complete it'll ASSERT().
31 // QNCPortWrite(Port#, Offset, Value)
34 // Set the fixed PRI Status encodings config.
37 QUARK_NC_MEMORY_ARBITER_SB_PORT_ID
,
38 QUARK_NC_MEMORY_ARBITER_REG_ASTATUS
,
39 QNC_FIXED_CONFIG_ASTATUS
42 // Sideband register write to Remote Management Unit
43 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QNC_MSG_TMPM_REG_PMBA
, (BIT31
| PcdGet16 (PcdPmbaIoBaseAddress
)));
45 // Configurable I/O address in iLB (legacy block)
47 LpcPciCfg32 (R_QNC_LPC_SMBUS_BASE
) = BIT31
| PcdGet16 (PcdSmbaIoBaseAddress
);
48 LpcPciCfg32 (R_QNC_LPC_GBA_BASE
) = BIT31
| PcdGet16 (PcdGbaIoBaseAddress
);
49 LpcPciCfg32 (R_QNC_LPC_PM1BLK
) = BIT31
| PcdGet16 (PcdPm1blkIoBaseAddress
);
50 LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) = BIT31
| PcdGet16 (PcdGpe0blkIoBaseAddress
);
51 LpcPciCfg32 (R_QNC_LPC_WDTBA
) = BIT31
| PcdGet16 (PcdWdtbaIoBaseAddress
);
54 // Program RCBA Base Address
56 LpcPciCfg32AndThenOr (R_QNC_LPC_RCBA
, (~B_QNC_LPC_RCBA_MASK
), (((UINT32
)(PcdGet64 (PcdRcbaMmioBaseAddress
))) | B_QNC_LPC_RCBA_EN
));
59 // Program Memory Manager fixed config values.
62 RegValue
= QNCPortRead (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID
, QUARK_NC_MEMORY_MANAGER_BTHCTRL
);
63 RegValue
&= ~(DRAM_NON_HOST_RQ_LIMIT_MASK
);
64 RegValue
|= (V_DRAM_NON_HOST_RQ_LIMIT
<< DRAM_NON_HOST_RQ_LIMIT_BP
);
65 QNCPortWrite (QUARK_NC_MEMORY_MANAGER_SB_PORT_ID
, QUARK_NC_MEMORY_MANAGER_BTHCTRL
, RegValue
);
68 // Program iCLK fixed config values.
72 (UINT32
) ~(B_MUXTOP_FLEX2_MASK
| B_MUXTOP_FLEX1_MASK
),
73 (V_MUXTOP_FLEX2
<< B_MUXTOP_FLEX2_BP
) | (V_MUXTOP_FLEX1
<< B_MUXTOP_FLEX1_BP
)
76 QUARK_ICLK_REF2_DBUFF0
,
77 (UINT32
) ~(BIT0
), // bit[0] cleared
94 // Set RMU DMA disable bit post boot.
96 RegValue
= QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_OPTIONS_1
);
97 RegValue
|= OPTIONS_1_DMA_DISABLE
;
98 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_OPTIONS_1
, RegValue
);
102 Do north cluster init which needs to be done AFTER MRC init.
116 // Program SVID/SID the same as VID/DID for all devices except root ports.
118 QNCMmPci32(0, MC_BUS
, MC_DEV
, MC_FUN
, R_EFI_PCI_SVID
) = QNCMmPci32(0, MC_BUS
, MC_DEV
, MC_FUN
, PCI_VENDOR_ID_OFFSET
);
119 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
);
120 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
);
121 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
);
126 Used to check QNC if it's S3 state. Clear the register state after query.
128 @retval TRUE if it's S3 state.
129 @retval FALSE if it's not S3 state.
134 QNCCheckS3AndClearState (
138 BOOLEAN S3WakeEventFound
;
147 S3WakeEventFound
= FALSE
;
151 // Read the ACPI registers,
153 Pm1Sts
= IoRead16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1S
);
154 Pm1En
= IoRead16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1E
);
155 Pm1Cnt
= IoRead16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
);
156 Gpe0Sts
= IoRead32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_GPE0S
);
157 Gpe0En
= IoRead32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_GPE0E
);
160 // Clear Power Management 1 Enable Register and
161 // General Purpost Event 0 Enables Register
163 IoWrite16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1E
, 0);
164 IoWrite32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_GPE0E
, 0);
166 if ((Pm1Sts
& B_QNC_PM1BLK_PM1S_WAKE
) != 0 && (Pm1Cnt
& B_QNC_PM1BLK_PM1C_SLPTP
) == V_S3
) {
169 // Detect the actual WAKE event
171 if ((Pm1Sts
& B_QNC_PM1BLK_PM1S_RTC
) && (Pm1En
& B_QNC_PM1BLK_PM1E_RTC
)) {
172 EventDescStr
= "RTC Alarm";
173 S3WakeEventFound
= TRUE
;
175 if ((Pm1Sts
& B_QNC_PM1BLK_PM1S_PCIEWSTS
) && !(Pm1En
& B_QNC_PM1BLK_PM1E_PWAKED
)) {
176 EventDescStr
= "PCIe WAKE";
177 S3WakeEventFound
= TRUE
;
179 if ((Gpe0Sts
& B_QNC_GPE0BLK_GPE0S_PCIE
) && (Gpe0En
& B_QNC_GPE0BLK_GPE0E_PCIE
)) {
180 EventDescStr
= "PCIe";
181 S3WakeEventFound
= TRUE
;
183 if ((Gpe0Sts
& B_QNC_GPE0BLK_GPE0S_GPIO
) && (Gpe0En
& B_QNC_GPE0BLK_GPE0E_GPIO
)) {
184 EventDescStr
= "GPIO";
185 S3WakeEventFound
= TRUE
;
187 if ((Gpe0Sts
& B_QNC_GPE0BLK_GPE0S_EGPE
) && (Gpe0En
& B_QNC_GPE0BLK_GPE0E_EGPE
)) {
188 EventDescStr
= "Ext. GPE";
189 S3WakeEventFound
= TRUE
;
191 if (S3WakeEventFound
== FALSE
) {
192 EventDescStr
= "Unknown";
194 DEBUG ((EFI_D_INFO
, "S3 Wake Event - %a\n", EventDescStr
));
197 // If no Power Button Override event occurs and one enabled wake event occurs,
198 // just do S3 resume and clear the state.
200 IoWrite16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
, (Pm1Cnt
& (~B_QNC_PM1BLK_PM1C_SLPTP
)));
203 // Set EOS to de Assert SMI
205 IoWrite32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_SMIS
, B_QNC_GPE0BLK_SMIS_EOS
);
208 // Enable SMI globally
210 NewValue
= QNCPortRead (QUARK_NC_HOST_BRIDGE_SB_PORT_ID
, QNC_MSG_FSBIC_REG_HMISC
);
212 QNCPortWrite (QUARK_NC_HOST_BRIDGE_SB_PORT_ID
, QNC_MSG_FSBIC_REG_HMISC
, NewValue
);
221 Used to check QNC if system wakes up from power on reset. Clear the register state after query.
223 @retval TRUE if system wakes up from power on reset
224 @retval FALSE if system does not wake up from power on reset
229 QNCCheckPowerOnResetAndClearState (
237 // Read the ACPI registers,
238 // PM1_STS information cannot be lost after power down, unless CMOS is cleared.
240 Pm1Sts
= IoRead16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1S
);
241 Pm1Cnt
= IoRead16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
);
244 // If B_SLP_TYP is S5
246 if ((Pm1Sts
& B_QNC_PM1BLK_PM1S_WAKE
) != 0 && (Pm1Cnt
& B_QNC_PM1BLK_PM1C_SLPTP
) == V_S5
) {
247 IoWrite16 (PcdGet16 (PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
, (Pm1Cnt
& (~B_QNC_PM1BLK_PM1C_SLPTP
)));
255 This function is used to clear SMI and wake status.
268 // Read the ACPI registers
270 Gpe0Sts
= IoRead32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_GPE0S
);
271 SmiSts
= IoRead32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_SMIS
);
274 // Clear any SMI or wake state from the boot
276 Gpe0Sts
|= B_QNC_GPE0BLK_GPE0S_ALL
;
277 SmiSts
|= B_QNC_GPE0BLK_SMIS_ALL
;
282 IoWrite32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_GPE0S
, Gpe0Sts
);
283 IoWrite32 ((UINT16
)(LpcPciCfg32 (R_QNC_LPC_GPE0BLK
) & 0xFFFF) + R_QNC_GPE0BLK_SMIS
, SmiSts
);
286 /** Send DRAM Ready opcode.
288 @param[in] OpcodeParam Parameter to DRAM ready opcode.
294 QNCSendOpcodeDramReady (
295 IN UINT32 OpcodeParam
300 // Before sending DRAM ready place invalid value in Scrub Config.
303 QUARK_NC_RMU_SB_PORT_ID
,
304 QUARK_NC_ECC_SCRUB_CONFIG_REG
,
309 // Send opcode and use param to notify HW of new RMU firmware location.
311 McD0PciCfg32 (QNC_ACCESS_PORT_MDR
) = OpcodeParam
;
312 McD0PciCfg32 (QNC_ACCESS_PORT_MCR
) = MESSAGE_SHADOW_DW (QUARK_NC_RMU_SB_PORT_ID
, 0);
315 // HW completed tasks on DRAM ready when scrub config read back as zero.
317 while (QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_ECC_SCRUB_CONFIG_REG
) != 0) {
318 MicroSecondDelay (10);
324 Relocate RMU Main binary to memory after MRC to improve performance.
326 @param[in] DestBaseAddress - Specify the new memory address for the RMU Main binary.
327 @param[in] SrcBaseAddress - Specify the current memory address for the RMU Main binary.
328 @param[in] Size - Specify size of the RMU Main binary.
336 IN CONST UINT32 DestBaseAddress
,
337 IN CONST UINT32 SrcBaseAddress
,
342 // Shadow RMU Main binary into main memory.
344 CopyMem ((VOID
*)(UINTN
)DestBaseAddress
,(VOID
*)(UINTN
) SrcBaseAddress
, Size
);
349 Get the total memory size
354 QNCGetTotalMemorysize (
358 return QNCPortRead(QUARK_NC_HOST_BRIDGE_SB_PORT_ID
, QUARK_NC_HOST_BRIDGE_HMBOUND_REG
) & HMBOUND_MASK
;
363 Get the memory range of TSEG.
364 The TSEG's memory is below TOLM.
366 @param[out] BaseAddress The base address of TSEG's memory range
367 @param[out] MemorySize The size of TSEG's memory range
372 QNCGetTSEGMemoryRange (
373 OUT UINT64
*BaseAddress
,
374 OUT UINT64
*MemorySize
378 UINT64 SMMAddress
= 0;
380 Register
= QncHsmmcRead ();
383 // Get the SMRAM Base address
385 SMMAddress
= Register
& SMM_START_MASK
;
386 *BaseAddress
= LShift16 (SMMAddress
);
389 // Get the SMRAM size
391 SMMAddress
= ((Register
& SMM_END_MASK
) | (~SMM_END_MASK
)) + 1;
392 *MemorySize
= SMMAddress
- (*BaseAddress
);
396 "TSEG's memory range: BaseAddress = 0x%x, Size = 0x%x\n",
397 (UINT32
)*BaseAddress
,
403 Updates the PAM registers in the MCH for the requested range and mode.
405 @param Start The start address of the memory region
406 @param Length The length, in bytes, of the memory region
407 @param ReadEnable Pointer to the boolean variable on whether to enable read for legacy memory section.
408 If NULL, then read attribute will not be touched by this call.
409 @param ReadEnable Pointer to the boolean variable on whether to enable write for legacy memory section.
410 If NULL, then write attribute will not be touched by this call.
411 @param Granularity A pointer to granularity, in bytes, that the PAM registers support
413 @retval RETURN_SUCCESS The PAM registers in the MCH were updated
414 @retval RETURN_INVALID_PARAMETER The memory range is not valid in legacy region.
419 QNCLegacyRegionManipulation (
422 IN BOOLEAN
*ReadEnable
,
423 IN BOOLEAN
*WriteEnable
,
424 OUT UINT32
*Granularity
428 // Do nothing cos no such support on QNC
430 return RETURN_SUCCESS
;
434 Determine if QNC is supported.
436 @retval FALSE QNC is not supported.
437 @retval TRUE QNC is supported.
448 SocVendorId
= MmioRead16 (
449 PciDeviceMmBase (MC_BUS
,
451 MC_FUN
) + PCI_VENDOR_ID_OFFSET
454 SocDeviceId
= QncGetSocDeviceId();
457 // Verify that this is a supported chipset
459 if ((SocVendorId
!= QUARK_MC_VENDOR_ID
) || ((SocDeviceId
!= QUARK_MC_DEVICE_ID
) && (SocDeviceId
!= QUARK2_MC_DEVICE_ID
))) {
460 DEBUG ((DEBUG_ERROR
, "QNC code doesn't support the Soc VendorId:0x%04x Soc DeviceId:0x%04x!\n", SocVendorId
, SocDeviceId
));
467 Get the DeviceId of the SoC
469 @retval PCI DeviceId of the SoC
479 SocDeviceId
= MmioRead16 (
484 ) + PCI_DEVICE_ID_OFFSET
491 Enable SMI detection of legacy flash access violations.
495 QncEnableLegacyFlashAccessViolationSmi (
501 BcValue
= LpcPciCfg32 (R_QNC_LPC_BIOS_CNTL
);
504 // Clear BIOSWE & set BLE.
506 BcValue
&= (~B_QNC_LPC_BIOS_CNTL_BIOSWE
);
507 BcValue
|= (B_QNC_LPC_BIOS_CNTL_BLE
);
509 LpcPciCfg32 (R_QNC_LPC_BIOS_CNTL
) = BcValue
;
511 DEBUG ((EFI_D_INFO
, "BIOS Control Lock Enabled!\n"));
515 Setup RMU Thermal sensor registers for Vref mode.
519 QNCThermalSensorSetVRefMode (
525 UINT32 Tscgf2Config2
;
527 Tscgf1Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF1_CONFIG
);
528 Tscgf2Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG
);
529 Tscgf2Config2
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG2
);
531 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_ISNSCURRENTSEL_MASK
);
532 Tscgf1Config
|= (V_TSCGF1_CONFIG_ISNSCURRENTSEL_VREF_MODE
<< B_TSCGF1_CONFIG_ISNSCURRENTSEL_BP
);
534 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_IBGEN
);
535 Tscgf1Config
|= (V_TSCGF1_CONFIG_IBGEN_VREF_MODE
<< B_TSCGF1_CONFIG_IBGEN_BP
);
537 Tscgf2Config2
&= ~(B_TSCGF2_CONFIG2_ISPARECTRL_MASK
);
538 Tscgf2Config2
|= (V_TSCGF2_CONFIG2_ISPARECTRL_VREF_MODE
<< B_TSCGF2_CONFIG2_ISPARECTRL_BP
);
540 Tscgf2Config2
&= ~(B_TSCGF2_CONFIG2_ICALCOARSETUNE_MASK
);
541 Tscgf2Config2
|= (V_TSCGF2_CONFIG2_ICALCOARSETUNE_VREF_MODE
<< B_TSCGF2_CONFIG2_ICALCOARSETUNE_BP
);
543 Tscgf2Config
&= ~(B_TSCGF2_CONFIG_IDSCONTROL_MASK
);
544 Tscgf2Config
|= (V_TSCGF2_CONFIG_IDSCONTROL_VREF_MODE
<< B_TSCGF2_CONFIG_IDSCONTROL_BP
);
546 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF1_CONFIG
, Tscgf1Config
);
547 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG
, Tscgf2Config
);
548 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG2
, Tscgf2Config2
);
552 Setup RMU Thermal sensor registers for Ratiometric mode.
556 QNCThermalSensorSetRatiometricMode (
562 UINT32 Tscgf2Config2
;
565 Tscgf1Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF1_CONFIG
);
566 Tscgf2Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG
);
567 Tscgf2Config2
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG2
);
568 Tscgf3Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF3_CONFIG
);
570 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_ISNSCURRENTSEL_MASK
);
571 Tscgf1Config
|= (V_TSCGF1_CONFIG_ISNSCURRENTSEL_RATIO_MODE
<< B_TSCGF1_CONFIG_ISNSCURRENTSEL_BP
);
573 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_ISNSCHOPSEL_MASK
);
574 Tscgf1Config
|= (V_TSCGF1_CONFIG_ISNSCHOPSEL_RATIO_MODE
<< B_TSCGF1_CONFIG_ISNSCHOPSEL_BP
);
576 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_ISNSINTERNALVREFEN
);
577 Tscgf1Config
|= (V_TSCGF1_CONFIG_ISNSINTERNALVREFEN_RATIO_MODE
<< B_TSCGF1_CONFIG_ISNSINTERNALVREFEN_BP
);
579 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_IBGEN
);
580 Tscgf1Config
|= (V_TSCGF1_CONFIG_IBGEN_RATIO_MODE
<< B_TSCGF1_CONFIG_IBGEN_BP
);
582 Tscgf1Config
&= ~(B_TSCGF1_CONFIG_IBGCHOPEN
);
583 Tscgf1Config
|= (V_TSCGF1_CONFIG_IBGCHOPEN_RATIO_MODE
<< B_TSCGF1_CONFIG_IBGCHOPEN_BP
);
585 Tscgf2Config2
&= ~(B_TSCGF2_CONFIG2_ICALCONFIGSEL_MASK
);
586 Tscgf2Config2
|= (V_TSCGF2_CONFIG2_ICALCONFIGSEL_RATIO_MODE
<< B_TSCGF2_CONFIG2_ICALCONFIGSEL_BP
);
588 Tscgf2Config2
&= ~(B_TSCGF2_CONFIG2_ISPARECTRL_MASK
);
589 Tscgf2Config2
|= (V_TSCGF2_CONFIG2_ISPARECTRL_RATIO_MODE
<< B_TSCGF2_CONFIG2_ISPARECTRL_BP
);
591 Tscgf2Config2
&= ~(B_TSCGF2_CONFIG2_ICALCOARSETUNE_MASK
);
592 Tscgf2Config2
|= (V_TSCGF2_CONFIG2_ICALCOARSETUNE_RATIO_MODE
<< B_TSCGF2_CONFIG2_ICALCOARSETUNE_BP
);
594 Tscgf2Config
&= ~(B_TSCGF2_CONFIG_IDSCONTROL_MASK
);
595 Tscgf2Config
|= (V_TSCGF2_CONFIG_IDSCONTROL_RATIO_MODE
<< B_TSCGF2_CONFIG_IDSCONTROL_BP
);
597 Tscgf2Config
&= ~(B_TSCGF2_CONFIG_IDSTIMING_MASK
);
598 Tscgf2Config
|= (V_TSCGF2_CONFIG_IDSTIMING_RATIO_MODE
<< B_TSCGF2_CONFIG_IDSTIMING_BP
);
600 Tscgf3Config
&= ~(B_TSCGF3_CONFIG_ITSGAMMACOEFF_MASK
);
601 Tscgf3Config
|= (V_TSCGF3_CONFIG_ITSGAMMACOEFF_RATIO_MODE
<< B_TSCGF3_CONFIG_ITSGAMMACOEFF_BP
);
603 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF1_CONFIG
, Tscgf1Config
);
604 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG
, Tscgf2Config
);
605 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF2_CONFIG2
, Tscgf2Config2
);
606 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF3_CONFIG
, Tscgf3Config
);
610 Setup RMU Thermal sensor trip point values.
612 @param[in] CatastrophicTripOnDegreesCelsius - Catastrophic set trip point threshold.
613 @param[in] HotTripOnDegreesCelsius - Hot set trip point threshold.
614 @param[in] HotTripOffDegreesCelsius - Hot clear trip point threshold.
616 @retval EFI_SUCCESS Trip points setup.
617 @retval EFI_INVALID_PARAMETER Invalid trip point value.
622 QNCThermalSensorSetTripValues (
623 IN CONST UINTN CatastrophicTripOnDegreesCelsius
,
624 IN CONST UINTN HotTripOnDegreesCelsius
,
625 IN CONST UINTN HotTripOffDegreesCelsius
628 UINT32 RegisterValue
;
631 // Register fields are 8-bit temperature values of granularity 1 degree C
632 // where 0x00 corresponds to -50 degrees C
633 // and 0xFF corresponds to 205 degrees C.
635 // User passes unsigned values in degrees Celsius so trips < 0 not supported.
637 // Add 50 to user values to get values for register fields.
640 if ((CatastrophicTripOnDegreesCelsius
> 205) || (HotTripOnDegreesCelsius
> 205) || (HotTripOffDegreesCelsius
> 205)) {
641 return EFI_INVALID_PARAMETER
;
648 ((0 + 50) << TS_CAT_TRIP_CLEAR_THOLD_BP
) | // Cat Trip Clear value must be less than Cat Trip Set Value.
649 ((CatastrophicTripOnDegreesCelsius
+ 50) << TS_CAT_TRIP_SET_THOLD_BP
) |
650 ((HotTripOnDegreesCelsius
+ 50) << TS_HOT_TRIP_SET_THOLD_BP
) |
651 ((HotTripOffDegreesCelsius
+ 50) << TS_HOT_TRIP_CLEAR_THOLD_BP
)
654 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_TS_TRIP
, RegisterValue
);
660 Enable RMU Thermal sensor with a Catastrophic Trip point.
662 @retval EFI_SUCCESS Trip points setup.
663 @retval EFI_INVALID_PARAMETER Invalid trip point value.
668 QNCThermalSensorEnableWithCatastrophicTrip (
669 IN CONST UINTN CatastrophicTripOnDegreesCelsius
677 // Trip Register fields are 8-bit temperature values of granularity 1 degree C
678 // where 0x00 corresponds to -50 degrees C
679 // and 0xFF corresponds to 205 degrees C.
681 // User passes unsigned values in degrees Celsius so trips < 0 not supported.
683 // Add 50 to user values to get values for register fields.
686 if (CatastrophicTripOnDegreesCelsius
> 205) {
687 return EFI_INVALID_PARAMETER
;
690 Tscgf3Config
= QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF3_CONFIG
);
691 TsModeReg
= QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_TS_MODE
);
692 TsTripReg
= QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_TS_TRIP
);
695 // Setup Catastrophic Trip point.
697 TsTripReg
&= ~(TS_CAT_TRIP_SET_THOLD_MASK
);
698 TsTripReg
|= ((CatastrophicTripOnDegreesCelsius
+ 50) << TS_CAT_TRIP_SET_THOLD_BP
);
699 TsTripReg
&= ~(TS_CAT_TRIP_CLEAR_THOLD_MASK
);
700 TsTripReg
|= ((0 + 50) << TS_CAT_TRIP_CLEAR_THOLD_BP
); // Cat Trip Clear value must be less than Cat Trip Set Value.
701 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_TS_TRIP
, TsTripReg
);
704 // To enable the TS do the following:
705 // 1) Take the TS out of reset by setting itsrst to 0x0.
706 // 2) Enable the TS using RMU Thermal sensor mode register.
709 Tscgf3Config
&= ~(B_TSCGF3_CONFIG_ITSRST
);
710 TsModeReg
|= TS_ENABLE
;
712 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_TSCGF3_CONFIG
, Tscgf3Config
);
713 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_TS_MODE
, TsModeReg
);
719 Lock all RMU Thermal sensor control & trip point registers.
724 QNCThermalSensorLockAllRegisters (
731 LockMask
= TS_LOCK_THRM_CTRL_REGS_ENABLE
| TS_LOCK_AUX_TRIP_PT_REGS_ENABLE
;
733 RegValue
= QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_CONFIG
);
734 RegValue
|= LockMask
;
735 QNCPortWrite (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_CONFIG
, RegValue
);
737 ASSERT ((LockMask
== (QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_CONFIG
) & LockMask
)));
741 Set chipset policy for double bit ECC error.
743 @param[in] PolicyValue Policy to config on double bit ECC error.
748 QNCPolicyDblEccBitErr (
749 IN CONST UINT32 PolicyValue
753 Register
= QNCPortRead (QUARK_NC_RMU_SB_PORT_ID
, QUARK_NC_RMU_REG_WDT_CONTROL
);
754 Register
&= ~(B_WDT_CONTROL_DBL_ECC_BIT_ERR_MASK
);
755 Register
|= PolicyValue
;
757 QUARK_NC_RMU_SB_PORT_ID
,
758 QUARK_NC_RMU_REG_WDT_CONTROL
,
764 Determine if running on secure Quark hardware Sku.
766 @retval FALSE Base Quark Sku or unprovisioned Secure Sku running.
767 @retval TRUE Provisioned SecureSku hardware running.
771 QncIsSecureProvisionedSku (
775 // Read QUARK Secure SKU Fuse
776 return ((QNCAltPortRead (QUARK_SCSS_FUSE_SB_PORT_ID
, QUARK_SCSS_SOC_UNIT_SPI_ROM_FUSE
) & BIT6
) == BIT6
);