blob: 920539d57163f26c7fae5d4b53f45662e6284b81 [file] [log] [blame]
Kerry Sheh3439bba2012-02-01 13:55:13 +08001/*****************************************************************************
2 *
3 * Copyright (C) 2012 Advanced Micro Devices, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 *
29 ***************************************************************************/
30
31
32#include "Platform.h"
33
34void DispatcherEntry(void *pConfig){
35
Kerry Sheh3439bba2012-02-01 13:55:13 +080036//#if CIM_DEBUG
37// InitSerialOut();
38//#endif
39
40 TRACE((DMSG_SB_TRACE, "CIM - SB700 Entry\n"));
41
Kerry Sheh3439bba2012-02-01 13:55:13 +080042 saveConfigPointer(pConfig);
43
44 if (((STDCFG*)pConfig)->Func == SB_POWERON_INIT)
45 sbPowerOnInit((AMDSBCFG*)pConfig);
46
Kerry Sheh3439bba2012-02-01 13:55:13 +080047 if (((STDCFG*)pConfig)->Func == SB_BEFORE_PCI_INIT)
48 sbBeforePciInit((AMDSBCFG*)pConfig);
49 if (((STDCFG*)pConfig)->Func == SB_AFTER_PCI_INIT)
50 sbAfterPciInit((AMDSBCFG*)pConfig);
51 if (((STDCFG*)pConfig)->Func == SB_LATE_POST_INIT)
52 sbLatePost((AMDSBCFG*)pConfig);
53 if (((STDCFG*)pConfig)->Func == SB_BEFORE_PCI_RESTORE_INIT)
54 sbBeforePciRestoreInit((AMDSBCFG*)pConfig);
55 if (((STDCFG*)pConfig)->Func == SB_AFTER_PCI_RESTORE_INIT)
56 sbAfterPciRestoreInit((AMDSBCFG*)pConfig);
57 if (((STDCFG*)pConfig)->Func == SB_SMM_SERVICE)
58 {
59 // sbSmmService((AMDSBCFG*)pConfig);
60 }
61 if (((STDCFG*)pConfig)->Func == SB_SMM_ACPION)
62 sbSmmAcpiOn((AMDSBCFG*)pConfig);
Kyösti Mälkki318e2ac2016-04-18 14:34:18 +030063
Kerry Sheh3439bba2012-02-01 13:55:13 +080064 TRACE((DMSG_SB_TRACE, "CIMx - SB Exit\n"));
65}
66
Kerry Sheh3439bba2012-02-01 13:55:13 +080067UINT32 GetPciebase(){
68 AMDSBCFG* Result;
69 Result = getConfigPointer();
70 return Result->StdHeader.pPcieBase;
71}
72
73
74void saveConfigPointer(AMDSBCFG* pConfig){
75 UINT8 dbReg, i;
76 UINT32 ddValue;
77
Stefan Reinauerd91ddc82015-07-30 11:17:40 -070078 ddValue = ((UINTN) pConfig);
Kerry Sheh3439bba2012-02-01 13:55:13 +080079 dbReg = SB_ECMOS_REG08;
80
81 for (i=0; i<=3; i++){
82 WriteIO(SB_IOMAP_REG72, AccWidthUint8, &dbReg);
83 WriteIO(SB_IOMAP_REG73, AccWidthUint8, (UINT8 *)&ddValue);
84 ddValue >>= 8;
85 dbReg++;
86 }
87}
88
89
90AMDSBCFG* getConfigPointer(){
91 UINT8 dbReg, dbValue, i;
Stefan Reinauerd91ddc82015-07-30 11:17:40 -070092 UINTN ddValue=0;
Kerry Sheh3439bba2012-02-01 13:55:13 +080093
94 dbReg = SB_ECMOS_REG08;
95 for (i=0; i<=3; i++){
96 WriteIO(SB_IOMAP_REG72, AccWidthUint8, &dbReg);
97 ReadIO(SB_IOMAP_REG73, AccWidthUint8, &dbValue);
98 ddValue |= (dbValue<<(i*8));
99 dbReg++;
100 }
101 return( (AMDSBCFG*) ddValue);
102}
103
104/**
105 * AmdSbDispatcher - Dispatch Southbridge function
106 *
107 *
108 *
109 * @param[in] pConfig Southbridge configuration structure pointer.
110 *
111 */
112AGESA_STATUS
113AmdSbDispatcher (
114 IN VOID *pConfig
115 )
116{
117 AGESA_STATUS Status = AGESA_SUCCESS;
118
119 saveConfigPointer (pConfig);
120
121 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_POWERON_INIT ) {
122 sbPowerOnInit ((AMDSBCFG*) pConfig);
123 }
124
125 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_BEFORE_PCI_INIT ) {
126 sbBeforePciInit ((AMDSBCFG*)pConfig);
127 }
128
129 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_AFTER_PCI_INIT ) {
130 sbAfterPciInit ((AMDSBCFG*)pConfig);
131 }
132
133 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_LATE_POST_INIT ) {
134 sbLatePost ((AMDSBCFG*)pConfig);
135 }
136
137 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_BEFORE_PCI_RESTORE_INIT ) {
138 sbBeforePciRestoreInit ((AMDSBCFG*)pConfig);
139 }
140
141 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_AFTER_PCI_RESTORE_INIT ) {
142 sbAfterPciRestoreInit ((AMDSBCFG*)pConfig);
143 }
144
145 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_SMM_SERVICE ) {
146 sbSmmService ((AMDSBCFG*)pConfig);
147 }
148
149 if ( ((AMD_CONFIG_PARAMS*)pConfig)->Func == SB_SMM_ACPION ) {
150 sbSmmAcpiOn ((AMDSBCFG*)pConfig);
151 }
152
153 return Status;
154}