2 This PEIM will parse the hoblist from fsp and report them into pei core.
3 This file contains the main entrypoint of the PEIM.
5 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <Library/IoLib.h>
13 #include <Library/SerialPortLib.h>
18 #define PCI_LPC_BASE (0x8000F800)
19 #define PCI_LPC_REG(x) (PCI_LPC_BASE + (x))
21 #define PMC_BASE_ADDRESS 0xFED03000 // PMC Memory Base Address
22 #define R_PCH_LPC_PMC_BASE 0x44 // PBASE, 32bit, 512 Bytes
23 #define B_PCH_LPC_PMC_BASE_EN BIT1 // Enable Bit
24 #define R_PCH_PMC_GEN_PMCON_1 0x20 // General PM Configuration 1
25 #define B_PCH_PMC_GEN_PMCON_SUS_PWR_FLR BIT14 // SUS Well Power Failure
26 #define B_PCH_PMC_GEN_PMCON_PWROK_FLR BIT16 // PWROK Failure
28 #define R_PCH_LPC_UART_CTRL 0x80 // UART Control
29 #define B_PCH_LPC_UART_CTRL_COM1_EN BIT0 // COM1 Enable
31 #define ILB_BASE_ADDRESS 0xFED08000 // ILB Memory Base Address
32 #define R_PCH_ILB_IRQE 0x88 // IRQ Enable Control
34 #define IO_BASE_ADDRESS 0xFED0C000 // IO Memory Base Address
36 #define V_PCH_ILB_IRQE_UARTIRQEN_IRQ3 BIT3 // UART IRQ3 Enable
37 #define V_PCH_ILB_IRQE_UARTIRQEN_IRQ4 BIT4 // UART IRQ4 Enable
38 #define PCIEX_BASE_ADDRESS 0xE0000000
39 #define PCI_EXPRESS_BASE_ADDRESS PCIEX_BASE_ADDRESS
40 #define PciD31F0RegBase PCIEX_BASE_ADDRESS + (UINT32) (31 << 15)
41 #define SB_RCBA 0xfed1c000
54 #define MmPciAddress( Segment, Bus, Device, Function, Register ) \
55 ( (UINTN)PCI_EXPRESS_BASE_ADDRESS + \
56 (UINTN)(Bus << 20) + \
57 (UINTN)(Device << 15) + \
58 (UINTN)(Function << 12) + \
62 #define DEFAULT_PCI_BUS_NUMBER_PCH 0
63 #define PCI_DEVICE_NUMBER_PCH_LPC 31
64 #define PCI_FUNCTION_NUMBER_PCH_LPC 0
66 #define R_PCH_LPC_RID_CC 0x08 // Revision ID & Class Code
68 #define V_PCH_LPC_RID_0 0x01 // A0 Stepping (17 x 17)
69 #define V_PCH_LPC_RID_1 0x02 // A0 Stepping (25 x 27)
70 #define V_PCH_LPC_RID_2 0x03 // A1 Stepping (17 x 17)
71 #define V_PCH_LPC_RID_3 0x04 // A1 Stepping (25 x 27)
72 #define V_PCH_LPC_RID_4 0x05 // B0 Stepping (17 x 17)
73 #define V_PCH_LPC_RID_5 0x06 // B0 Stepping (25 x 27)
74 #define V_PCH_LPC_RID_6 0x07 // B1 Stepping (17 x 17)
75 #define V_PCH_LPC_RID_7 0x08 // B1 Stepping (25 x 27)
76 #define V_PCH_LPC_RID_8 0x09 // B2 Stepping (17 x 17)
77 #define V_PCH_LPC_RID_9 0x0A // B2 Stepping (25 x 27)
78 #define V_PCH_LPC_RID_A 0x0B // B3 Stepping (17 x 17)
79 #define V_PCH_LPC_RID_B 0x0C // B3 Stepping (25 x 27)
80 #define V_PCH_LPC_RID_C 0x0D // C0 Stepping (17 x 17)
81 #define V_PCH_LPC_RID_D 0x0E // C0 Stepping (25 x 27)
84 Return Pch stepping type
88 @retval PCH_STEPPING Pch stepping type
101 DEFAULT_PCI_BUS_NUMBER_PCH
,
102 PCI_DEVICE_NUMBER_PCH_LPC
,
103 PCI_FUNCTION_NUMBER_PCH_LPC
,
108 case V_PCH_LPC_RID_0
:
109 case V_PCH_LPC_RID_1
:
113 case V_PCH_LPC_RID_2
:
114 case V_PCH_LPC_RID_3
:
118 case V_PCH_LPC_RID_4
:
119 case V_PCH_LPC_RID_5
:
123 case V_PCH_LPC_RID_6
:
124 case V_PCH_LPC_RID_7
:
128 case V_PCH_LPC_RID_8
:
129 case V_PCH_LPC_RID_9
:
133 case V_PCH_LPC_RID_A
:
134 case V_PCH_LPC_RID_B
:
138 case V_PCH_LPC_RID_C
:
139 case V_PCH_LPC_RID_D
:
144 return PchSteppingMax
;
151 Enable legacy decoding on ICH6
155 @retval EFI_SUCCESS Always returns success.
165 // Program and enable PMC Base.
167 IoWrite32 (PCI_IDX
, PCI_LPC_REG(R_PCH_LPC_PMC_BASE
));
168 IoWrite32 (PCI_DAT
, (PMC_BASE_ADDRESS
| B_PCH_LPC_PMC_BASE_EN
));
171 // Enable COM1 for debug message output.
173 MmioAndThenOr32 (PMC_BASE_ADDRESS
+ R_PCH_PMC_GEN_PMCON_1
, (UINT32
) (~(B_PCH_PMC_GEN_PMCON_SUS_PWR_FLR
+ B_PCH_PMC_GEN_PMCON_PWROK_FLR
)), BIT24
);
178 if (PchStepping()>= PchB0
)
179 MmioOr8 (ILB_BASE_ADDRESS
+ R_PCH_ILB_IRQE
, (UINT8
) V_PCH_ILB_IRQE_UARTIRQEN_IRQ4
);
181 MmioOr8 (ILB_BASE_ADDRESS
+ R_PCH_ILB_IRQE
, (UINT8
) V_PCH_ILB_IRQE_UARTIRQEN_IRQ3
);
182 MmioAnd32(IO_BASE_ADDRESS
+ 0x0520, (UINT32
)~(0x00000187));
183 MmioOr32 (IO_BASE_ADDRESS
+ 0x0520, (UINT32
)0x81); // UART3_RXD-L
184 MmioAnd32(IO_BASE_ADDRESS
+ 0x0530, (UINT32
)~(0x00000007));
185 MmioOr32 (IO_BASE_ADDRESS
+ 0x0530, (UINT32
)0x1); // UART3_RXD-L
186 MmioOr8 (PciD31F0RegBase
+ R_PCH_LPC_UART_CTRL
, (UINT8
) B_PCH_LPC_UART_CTRL_COM1_EN
);
188 SerialPortInitialize ();
189 SerialPortWrite ((UINT8
*)"EnableInternalUart!\r\n", sizeof("EnableInternalUart!\r\n") - 1);