4 * Config Southbridge GPP controller
8 * @xrefitem bom "File Content Label" "Release Content"
11 * @e \$Revision:$ @e \$Date:$
15 *****************************************************************************
17 * Copyright (c) 2011, Advanced Micro Devices, Inc.
18 * All rights reserved.
20 * 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.
31 * 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.
42 ****************************************************************************
44 #include "SbPlatform.h"
48 // Declaration of external functions
50 VOID sbGppDynamicPowerSaving (IN AMDSBCFG* pConfig );
51 VOID sbGppForceGen1 (IN AMDSBCFG* pConfig, IN CONST UINT8 ActivePorts);
52 VOID sbGppForceGen2 (IN AMDSBCFG* pConfig, IN CONST UINT8 ActivePorts);
53 UINT8 GppPortPollingLtssm (IN AMDSBCFG* pConfig, IN UINT8 ActivePorts, IN BOOLEAN IsGen2);
54 VOID SbStall (IN UINT32 uSec);
55 VOID outPort80 (IN UINT32 pcode);
57 // wtf Declaration ...
58 VOID sbGppHotPlugSmiProcess (IN AMDSBCFG* pConfig, IN UINT32 HpPort);
59 VOID sbGppHotUnplugSmiProcess (IN AMDSBCFG* pConfig, IN UINT32 HpPort);
60 VOID sbGppHotplugSmiCallback (IN AMDSBCFG* pConfig, IN BOOLEAN IsPlugged);
63 * GPP hot plug handler
66 * @param[in] pConfig Southbridge configuration structure pointer.
67 * @param[in] HpPort The hot plug port number.
71 VOID sbGppHotPlugSmiProcess (
78 // First restore GPP pads if needed
79 if (pConfig->GppDynamicPowerSaving && pConfig->AlinkPhyPllPowerDown && pConfig->GppPhyPllPowerDown) {
80 rwAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29), ~(UINT32) (1 << (12 + HpPort)), 0);
81 rwAlink (RC_INDXC_REG65, ~(UINT32) (0x101 << HpPort), 0);
85 FailedPort = (UINT8) (1 << HpPort);
86 if (pConfig->GppGen2 && pConfig->GppGen2Strap) {
87 if (GppPortPollingLtssm (pConfig, FailedPort, TRUE)) {
88 sbGppForceGen1 (pConfig, FailedPort);
89 FailedPort = GppPortPollingLtssm (pConfig, FailedPort, FALSE);
92 sbGppForceGen1 (pConfig, FailedPort);
93 FailedPort = GppPortPollingLtssm (pConfig, FailedPort, FALSE);
99 * GPP hot-unplug handler
102 * @param[in] pConfig Southbridge configuration structure pointer.
103 * @param[in] HpPort The hot plug port number.
107 sbGppHotUnplugSmiProcess (
108 IN AMDSBCFG* pConfig,
112 pConfig->PORTCONFIG[HpPort].PortCfg.PortDetected = FALSE;
114 if (pConfig->GppGen2 && pConfig->GppGen2Strap) {
115 sbGppForceGen2 (pConfig, (UINT8) (1 << HpPort));
118 // 5.19.1 GPP Power Saving with Hot Unplug
119 if (pConfig->GppDynamicPowerSaving && pConfig->AlinkPhyPllPowerDown && pConfig->GppPhyPllPowerDown) {
120 rwAlink (SB_RCINDXP_REGA2 | HpPort << 24, ~(UINT32) (BIT17), BIT17);
121 rwAlink (SB_RCINDXP_REGA2 | HpPort << 24, ~(UINT32) (BIT8), BIT8);
122 rwAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29), ~(UINT32) (1 << (12 + HpPort)), (1 << (12 + HpPort)));
123 rwAlink (SB_RCINDXP_REGA2 | HpPort << 24, ~(UINT32) (BIT17), 0);
125 // Finally re-configure GPP pads if needed
126 sbGppDynamicPowerSaving (pConfig);
132 * SMI handler for GPP hot-plug
135 * @param[in] pConfig Southbridge configuration structure pointer.
136 * @param[in] IsPlugged Is a card currently plugged in the GPP port?
140 sbGppHotplugSmiCallback (
141 IN AMDSBCFG* pConfig,
148 if (!pConfig->GppFunctionEnable) {
153 for (portNum = 0; portNum < MAX_GPP_PORTS; portNum++) {
154 if (pConfig->PORTCONFIG[portNum].PortCfg.PortHotPlug == TRUE) {
159 if (HpPort == 0xff) {
165 sbGppHotPlugSmiProcess (pConfig, HpPort);
168 sbGppHotUnplugSmiProcess (pConfig, HpPort);