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);
57 * GPP hot plug handler
60 * @param[in] pConfig Southbridge configuration structure pointer.
61 * @param[in] HpPort The hot plug port number.
65 sbGppHotPlugSmiProcess (
72 // First restore GPP pads if needed
73 if (pConfig->GppDynamicPowerSaving && pConfig->AlinkPhyPllPowerDown && pConfig->GppPhyPllPowerDown) {
74 rwAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29), ~(UINT32) (1 << (12 + HpPort)), 0);
75 rwAlink (RC_INDXC_REG65, ~(UINT32) (0x101 << HpPort), 0);
79 FailedPort = (UINT8) (1 << HpPort);
80 if (pConfig->GppGen2 && pConfig->GppGen2Strap) {
81 if (GppPortPollingLtssm (pConfig, FailedPort, TRUE)) {
82 sbGppForceGen1 (pConfig, FailedPort);
83 FailedPort = GppPortPollingLtssm (pConfig, FailedPort, FALSE);
86 sbGppForceGen1 (pConfig, FailedPort);
87 FailedPort = GppPortPollingLtssm (pConfig, FailedPort, FALSE);
93 * GPP hot-unplug handler
96 * @param[in] pConfig Southbridge configuration structure pointer.
97 * @param[in] HpPort The hot plug port number.
101 sbGppHotUnplugSmiProcess (
102 IN AMDSBCFG* pConfig,
106 pConfig->PORTCONFIG[HpPort].PortCfg.PortDetected = FALSE;
108 if (pConfig->GppGen2 && pConfig->GppGen2Strap) {
109 sbGppForceGen2 (pConfig, (UINT8) (1 << HpPort));
112 // 5.19.1 GPP Power Saving with Hot Unplug
113 if (pConfig->GppDynamicPowerSaving && pConfig->AlinkPhyPllPowerDown && pConfig->GppPhyPllPowerDown) {
114 rwAlink (SB_RCINDXP_REGA2 | HpPort << 24, ~(UINT32) (BIT17), BIT17);
115 rwAlink (SB_RCINDXP_REGA2 | HpPort << 24, ~(UINT32) (BIT8), BIT8);
116 rwAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29), ~(UINT32) (1 << (12 + HpPort)), (1 << (12 + HpPort)));
117 rwAlink (SB_RCINDXP_REGA2 | HpPort << 24, ~(UINT32) (BIT17), 0);
119 // Finally re-configure GPP pads if needed
120 sbGppDynamicPowerSaving (pConfig);
126 * SMI handler for GPP hot-plug
129 * @param[in] pConfig Southbridge configuration structure pointer.
130 * @param[in] IsPlugged Is a card currently plugged in the GPP port?
134 sbGppHotplugSmiCallback (
135 IN AMDSBCFG* pConfig,
142 if (!pConfig->GppFunctionEnable) {
147 for (portNum = 0; portNum < MAX_GPP_PORTS; portNum++) {
148 if (pConfig->PORTCONFIG[portNum].PortCfg.PortHotPlug == TRUE) {
153 if (HpPort == 0xff) {
159 sbGppHotPlugSmiProcess (pConfig, HpPort);
162 sbGppHotUnplugSmiProcess (pConfig, HpPort);