blob: b93e164ac45ec71cba823bd6edd5358d3e32dbbd [file] [log] [blame]
zbao7d94cf92012-07-02 14:19:14 +08001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * Misc common definition
6 *
7 *
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: GNB
12 * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
13 *
14 */
15/*
16*****************************************************************************
17*
Siyuan Wang641f00c2013-06-08 11:50:55 +080018 * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
19 * All rights reserved.
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 * * Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * * Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
30 * from this software without specific prior written permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zbao7d94cf92012-07-02 14:19:14 +080042* ***************************************************************************
43*
44*/
45#ifndef _GNB_H_
46#define _GNB_H_
47
Edward O'Callaghancd475602014-07-07 21:08:23 +100048#include <stdlib.h>
49
zbao7d94cf92012-07-02 14:19:14 +080050#pragma pack (push, 1)
51
52#define GNB_DEADLOOP() \
53{ \
54 VOLATILE BOOLEAN k; \
55 k = TRUE; \
56 while (k) { \
57 } \
58}
59#ifdef IDSOPT_TRACING_ENABLED
60 #if (IDSOPT_TRACING_ENABLED == TRUE)
61 #define GNB_TRACE_ENABLE
62 #endif
63#endif
64
65
66#ifndef GNB_DEBUG_CODE
67 #ifdef GNB_TRACE_ENABLE
68 #define GNB_DEBUG_CODE(Code) Code
69 #else
70 #define GNB_DEBUG_CODE(Code)
71 #endif
72#endif
73
zbao7d94cf92012-07-02 14:19:14 +080074#define OFF 0
75
76#define PVOID UINT64
77
78#define STRING_TO_UINT32(a, b, c, d) ((UINT32) ((d << 24) | (c << 16) | (b << 8) | a))
79
80#define GnbLibGetHeader(x) ((AMD_CONFIG_PARAMS*) (x)->StdHeader)
81
82#define AGESA_STATUS_UPDATE(Current, Aggregated) \
83if (Current > Aggregated) { \
84 Aggregated = Current; \
85}
86
87#ifndef offsetof
88 #define offsetof(s, m) (UINTN)&(((s *)0)->m)
89#endif
90
91
92//Table properties
93
94#define TABLE_PROPERTY_DEAFULT 0x00000000ul
95#define TABLE_PROPERTY_IGFX_DISABLED 0x00000001ul
96#define TABLE_PROPERTY_IOMMU_DISABLED 0x00000002ul
97#define TABLE_PROPERTY_LCLK_DEEP_SLEEP 0x00000004ul
98#define TABLE_PROPERTY_ORB_CLK_GATING 0x00000008ul
99#define TABLE_PROPERTY_IOC_LCLK_CLOCK_GATING 0x00000010ul
100#define TABLE_PROPERTY_IOC_SCLK_CLOCK_GATING 0x00000020ul
101#define TABLE_PROPERTY_IOMMU_L1_CLOCK_GATING 0x00000040ul
102#define TABLE_PROPERTY_IOMMU_L2_CLOCK_GATING 0x00000080ul
103#define TABLE_PROPERTY_BAPM 0x00000100ul
104#define TABLE_PROPERTY_SECONDARY_GNB 0x00000200ul
105#define TABLE_PROPERTY_NMI_SYNCFLOOD 0x00000400ul
106#define TABLE_PROPERTY_NBDPM 0x00000800ul
107#define TABLE_PROPERTY_LOADLINE_ENABLE 0x00001000ul
108#define TABLE_PROPERTY_SMU_SCLK_CLOCK_GATING 0x00002000ul
109
110//Register access flags Flags
111#define GNB_REG_ACC_FLAG_S3SAVE 0x00000001ul
112
113/// LCLK DPM enable control
114typedef enum {
115 LclkDpmDisabled, ///<LCLK DPM disabled
116 LclkDpmRcActivity, ///<LCLK DPM enabled and use Root Complex Activity monitor method
117} LCLK_DPM_MODE;
118
119
120/// Power gaiter data setting (do not change this structure definition)
121typedef struct {
122 UINT16 pwrdata0 ;
123 UINT16 pwrdata1 ;
124 UINT16 pwrdata2 ;
125 UINT16 pwrdata3 ;
126 UINT16 ResetTimer; ///< Reset Timer
127 UINT16 IsoTimer; ///< Isolation Timer
128} POWER_GATE_DATA;
129
130
131/// Topology information
132typedef struct {
133 BOOLEAN PhantomFunction; ///< PCIe topology have device with phantom function
134 BOOLEAN PcieToPciexBridge; ///< PCIe topology have device with Pcieto Pcix bridge
135} GNB_TOPOLOGY_INFO;
136
137
138/// GNB installable services
139typedef enum {
140 GnbPcieFamConfigService, ///< PCIe config service
141 GnbPcieFamInitService, ///< PCIe Init service
142 GnbPcieFamDebugService, ///< PCIe Debug service
143 GnbRegisterAccessService, ///< GNB register access service
144 GnbIommuService ///< GNB IOMMU config service
145} GNB_SERVICE_ID;
146
147/// GNB service entry
148typedef struct _GNB_SERVICE {
149 GNB_SERVICE_ID ServiceId; ///< Service ID
150 UINT64 Family; ///< CPU family
151 VOID *ServiceProtocol; ///< Service protocol
152 struct _GNB_SERVICE *NextService; ///< Pointer to next service
153} GNB_SERVICE;
154
155#define GNB_STRINGIZE(x) #x
156#define GNB_SERVICE_DEFINITIONS(x) GNB_STRINGIZE (Services/x/x.h)
157#define GNB_MODULE_DEFINITIONS(x) GNB_STRINGIZE (Modules/x/x.h)
158#define GNB_MODULE_INSTALL(x) GNB_STRINGIZE (Modules/x/x##Install.h)
159#pragma pack (pop)
160
161#endif