blob: 998b6b830c55512892ca34a7e47526a399860b9c [file] [log] [blame]
zbao7d94cf92012-07-02 14:19:14 +08001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * AMD AGESA CPU IO Cstate feature support code.
6 *
7 * Contains code that declares the AGESA CPU IO Cstate related APIs
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: CPU/Feature
12 * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
13 */
14/*
15 ******************************************************************************
16 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080017 * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
18 * All rights reserved.
zbao7d94cf92012-07-02 14:19:14 +080019 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080020 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions are met:
22 * * Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 * * Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the
26 * documentation and/or other materials provided with the distribution.
27 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
28 * its contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
zbao7d94cf92012-07-02 14:19:14 +080030 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080031 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
35 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zbao7d94cf92012-07-02 14:19:14 +080041 ******************************************************************************
42 */
43
44#ifndef _CPU_IO_CSTATE_H_
45#define _CPU_IO_CSTATE_H_
46
47/*----------------------------------------------------------------------------------------
48 * M I X E D (Definitions And Macros / Typedefs, Structures, Enums)
49 *----------------------------------------------------------------------------------------
50 */
51// Forward declaration needed for multi-structure mutual references
52AGESA_FORWARD_DECLARATION (IO_CSTATE_FAMILY_SERVICES);
53
54/*----------------------------------------------------------------------------------------
55 * D E F I N I T I O N S A N D M A C R O S
56 *----------------------------------------------------------------------------------------
57 */
58// Defines for ACPI C-State Objects
59#define CST_NAME__ '_'
60#define CST_NAME_C 'C'
61#define CST_NAME_S 'S'
62#define CST_NAME_T 'T'
63#define CST_LENGTH (CST_BODY_SIZE - 1)
64#define CST_NUM_OF_ELEMENTS 0x02
65#define CST_COUNT 0x01
66#define CST_PKG_LENGTH (CST_BODY_SIZE - 6) // CST_BODY_SIZE - PkgHeader - Count Buffer
67#define CST_PKG_ELEMENTS 0x04
68#define CST_SUBPKG_LENGTH 0x14
69#define CST_SUBPKG_ELEMENTS 0x0A
70#define CST_GDR_LENGTH 0x000C
71#define CST_C1_TYPE 0x01
72#define CST_C2_TYPE 0x02
73
74#define CSD_NAME_D 'D'
75#define CSD_COORD_TYPE_HW_ALL 0xFE
76
77/*----------------------------------------------------------------------------------------
78 * T Y P E D E F S A N D S T R U C T U R E S
79 *----------------------------------------------------------------------------------------
80 */
81/* AML code definition */
82
83/// CST Header
84typedef struct _CST_HEADER_STRUCT {
85 UINT8 NameOpcode; ///< Name Opcode
86 UINT8 CstName_a__; ///< String "_"
87 UINT8 CstName_a_C; ///< String "C"
88 UINT8 CstName_a_S; ///< String "S"
89 UINT8 CstName_a_T; ///< String "T"
90} CST_HEADER_STRUCT;
91#define CST_HEADER_SIZE 5
92
93/// CST Body
94typedef struct _CST_BODY_STRUCT {
95 UINT8 PkgOpcode; ///< Package Opcode
96 UINT8 PkgLength; ///< Package Length
97 UINT8 PkgElements; ///< Number of Elements
98 UINT8 BytePrefix; ///< Byte Prefix Opcode
99 UINT8 Count; ///< Number of Cstate info packages
100 UINT8 PkgOpcode2; ///< Package Opcode
101 UINT8 PkgLength2; ///< Package Length
102 UINT8 PkgElements2; ///< Number of Elements
103 UINT8 BufferOpcode; ///< Buffer Opcode
104 UINT8 BufferLength; ///< Buffer Length
105 UINT8 BufferElements; ///< Number of Elements
106 UINT8 BufferOpcode2; ///< Buffer Opcode
107 UINT8 GdrOpcode; ///< Generic Register Descriptor Opcode
108 UINT16 GdrLength; ///< Descriptor Length
109 UINT8 AddrSpaceId; ///< Address Space ID
110 UINT8 RegBitWidth; ///< Register Bit Width
111 UINT8 RegBitOffset; ///< Register Bit Offset
112 UINT8 AddressSize; ///< Address Size
113 UINT64 RegisterAddr; ///< Register Address
114 UINT16 EndTag; ///< End Tag Descriptor
115 UINT8 BytePrefix2; ///< Byte Prefix Opcode
116 UINT8 Type; ///< Type
117 UINT8 WordPrefix; ///< Word Prefix Opcode
118 UINT16 Latency; ///< Latency
119 UINT8 DWordPrefix; ///< Dword Prefix Opcode
120 UINT32 Power; ///< Power
121} CST_BODY_STRUCT;
122#define CST_BODY_SIZE 39
123
124/// CSD Header
125typedef struct _CSD_HEADER_STRUCT {
126 UINT8 NameOpcode; ///< Name Opcode
127 UINT8 CsdName_a__; ///< String "_"
128 UINT8 CsdName_a_C; ///< String "C"
129 UINT8 CsdName_a_S; ///< String "S"
130 UINT8 CsdName_a_D; ///< String "D"
131} CSD_HEADER_STRUCT;
132#define CSD_HEADER_SIZE 5
133
134/// CSD Body
135typedef struct _CSD_BODY_STRUCT {
136 UINT8 PkgOpcode; ///< Package Opcode
137 UINT8 PkgLength; ///< Package Length
138 UINT8 PkgElements; ///< Number of Elements
139 UINT8 PkgOpcode2; ///< Package Opcode
140 UINT8 PkgLength2; ///< Package Length
141 UINT8 PkgElements2; ///< Number of Elements
142 UINT8 BytePrefix; ///< Byte Prefix Opcode
143 UINT8 NumEntries; ///< Number of Entries
144 UINT8 BytePrefix2; ///< Byte Prefix Opcode
145 UINT8 Revision; ///< Revision
146 UINT8 DWordPrefix; ///< DWord Prefix Opcode
147 UINT32 Domain; ///< Dependency Domain Number
148 UINT8 DWordPrefix2; ///< DWord Prefix Opcode
149 UINT32 CoordType; ///< Coordination Type
150 UINT8 DWordPrefix3; ///< Dword Prefix Opcode
151 UINT32 NumProcessors; ///< Number of Processors in the Domain
152 UINT8 DWordPrefix4; ///< Dword Prefix Opcode
153 UINT32 Index; ///< Index of C-State entry for which dependency applies
154} CSD_BODY_STRUCT;
155#define CSD_BODY_SIZE 30
156
157/// input for create _CST
158typedef struct _ACPI_CST_CREATE_INPUT {
159 IO_CSTATE_FAMILY_SERVICES *IoCstateServices; ///< Family service of IoCstate
160 UINT8 LocalApicId; ///< Local Apic for create _CST
161 VOID **PstateAcpiBufferPtr; ///< buffer for fill _CST
162} ACPI_CST_CREATE_INPUT ;
163
164/// input for get _CST
165typedef struct _ACPI_CST_GET_INPUT {
166 IO_CSTATE_FAMILY_SERVICES *IoCstateServices; ///< Family service of IoCstate
167 PLATFORM_CONFIGURATION *PlatformConfig; ///< platform config
168 UINT32 *CStateAcpiObjSizePtr; ///< Point to size of _CST
169} ACPI_CST_GET_INPUT ;
170
171
172/*---------------------------------------------------------------------------------------*/
173/**
174 * Family specific call to check if IO Cstate is supported.
175 *
176 * @param[in] IoCstateServices IO Cstate services.
177 * @param[in] Socket Zero-based socket number.
178 * @param[in] StdHeader Config Handle for library, services.
179 *
180 * @retval TRUE IO Cstate is supported.
181 * @retval FALSE IO Cstate is not supported.
182 *
183 */
184typedef BOOLEAN F_IO_CSTATE_IS_SUPPORTED (
185 IN IO_CSTATE_FAMILY_SERVICES *IoCstateServices,
186 IN UINT32 Socket,
187 IN AMD_CONFIG_PARAMS *StdHeader
188 );
189
190/*---------------------------------------------------------------------------------------*/
191/**
192 * Family specific call to enable IO Cstate.
193 *
194 * @param[in] IoCstateServices IO Cstate services.
195 * @param[in] EntryPoint Timepoint designator.
196 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
197 * @param[in] StdHeader Config Handle for library, services.
198 *
199 * @return Family specific error value.
200 *
201 */
202typedef AGESA_STATUS F_IO_CSTATE_INIT (
203 IN IO_CSTATE_FAMILY_SERVICES *IoCstateServices,
204 IN UINT64 EntryPoint,
205 IN PLATFORM_CONFIGURATION *PlatformConfig,
206 IN AMD_CONFIG_PARAMS *StdHeader
207 );
208
209/*---------------------------------------------------------------------------------------*/
210/**
211 * Family specific call to return the size of ACPI C-State Objects
212 *
213 * @param[in] IoCstateServices IO Cstate services.
214 * @param[in] PlatformConfig Contains the runtime modifiable feature input data
215 * @param[in] StdHeader Config Handle for library, services.
216 *
217 * @retval Size of ACPI C-State Objects
218 *
219 */
220typedef UINT32 F_IO_CSTATE_GET_CST_SIZE (
221 IN IO_CSTATE_FAMILY_SERVICES *IoCstateServices,
222 IN PLATFORM_CONFIGURATION *PlatformConfig,
223 IN AMD_CONFIG_PARAMS *StdHeader
224 );
225
226/*---------------------------------------------------------------------------------------*/
227/**
228 * Family specific call to create ACPI C-State Objects
229 *
230 * @param[in] IoCstateServices IO Cstate services.
231 * @param[in] LocalApicId Local Apic Id
232 * @param[in, out] PstateAcpiBufferPtr Pointer to Pstate data buffer
233 * @param[in] StdHeader Config Handle for library, services.
234 *
235 */
236typedef VOID F_IO_CSTATE_CREATE_CST (
237 IN IO_CSTATE_FAMILY_SERVICES *IoCstateServices,
238 IN UINT8 LocalApicId,
239 IN OUT VOID **PstateAcpiBufferPtr,
240 IN AMD_CONFIG_PARAMS *StdHeader
241 );
242
243/*---------------------------------------------------------------------------------------*/
244/**
245 * Family specific call to check whether CSD object should be created.
246 *
247 * @param[in] IoCstateServices IO Cstate services.
248 * @param[in] StdHeader Config Handle for library, services.
249 *
250 * @retval TRUE CSD Object should be created.
251 * @retval FALSE CSD Object should not be created.
252 *
253 */
254typedef BOOLEAN F_IO_CSTATE_IS_CSD_GENERATED (
255 IN IO_CSTATE_FAMILY_SERVICES *IoCstateServices,
256 IN AMD_CONFIG_PARAMS *StdHeader
257 );
258
259/// Reference to a Method
260typedef F_IO_CSTATE_IS_SUPPORTED *PF_IO_CSTATE_IS_SUPPORTED;
261typedef F_IO_CSTATE_INIT *PF_IO_CSTATE_INIT;
262typedef F_IO_CSTATE_GET_CST_SIZE *PF_IO_CSTATE_GET_CST_SIZE;
263typedef F_IO_CSTATE_CREATE_CST *PF_IO_CSTATE_CREATE_CST;
264typedef F_IO_CSTATE_IS_CSD_GENERATED *PF_IO_CSTATE_IS_CSD_GENERATED;
265
266/**
267 * Provide the interface to the IO Cstate Family Specific Services.
268 *
269 * Use the methods or data in this struct to adapt the feature code to a specific cpu family or model (or stepping!).
270 * Each supported Family must provide an implementation for all methods in this interface, even if the
271 * implementation is a CommonReturn().
272 */
273struct _IO_CSTATE_FAMILY_SERVICES {
274 UINT16 Revision; ///< Interface version
275 // Public Methods.
276 PF_IO_CSTATE_IS_SUPPORTED IsIoCstateSupported; ///< Method: Family specific call to check if IO Cstate is supported.
277 PF_IO_CSTATE_INIT InitializeIoCstate; ///< Method: Family specific call to enable IO Cstate
278 PF_IO_CSTATE_GET_CST_SIZE GetAcpiCstObj; ///< Method: Family specific call to return the size of ACPI CST objects.
279 PF_IO_CSTATE_CREATE_CST CreateAcpiCstObj; ///< Method: Family specific call to create ACPI CST object
280 PF_IO_CSTATE_IS_CSD_GENERATED IsCsdObjGenerated; ///< Method: Family specific call to check whether CSD Object should be created.
281};
282
283#endif // _CPU_IO_CSTATE_H_