5 * Config Southbridge GPP controller
9 * @xrefitem bom "File Content Label" "Release Content"
12 * @e \$Revision:$ @e \$Date:$
16 *****************************************************************************
18 * Copyright (c) 2011, Advanced Micro Devices, Inc.
19 * All rights reserved.
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.
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.
43 ****************************************************************************
45 #include "SbPlatform.h"
50 * PCIE_CAP_ID - PCIe Cap ID
53 #define PCIE_CAP_ID 0x10
56 // Declaration of local functions
85 IN CONST UINT8 ActivePorts
91 IN CONST UINT8 ActivePorts
100 GppPortPollingLtssm (
101 IN AMDSBCFG* pConfig,
102 IN UINT8 ActivePorts,
117 sbGppDynamicPowerSaving (
122 sbGppAerInitialization (
127 sbGppRasInitialization (
132 // Declaration of external functions
137 * sbFindPciCap - Find PCI Cap
140 * @param[in] pciAddress PCI Address.
141 * @param[in] targetCapId Target Cap ID.
146 IN UINT32 pciAddress,
154 while (NextCapPtr != 0) {
155 ReadPCI (pciAddress + NextCapPtr, AccWidthUint8, &NextCapPtr);
156 if (NextCapPtr == 0xff) {
159 if (NextCapPtr != 0) {
160 ReadPCI (pciAddress + NextCapPtr, AccWidthUint8, &CapId);
161 if (CapId == targetCapId) {
172 * sbGppSetAspm - Set GPP ASPM
175 * @param[in] pciAddress PCI Address.
176 * @param[in] LxState Lane State.
181 IN UINT32 pciAddress,
188 pcieCapOffset = sbFindPciCap (pciAddress, PCIE_CAP_ID);
190 // Read link capabilities register (0x0C[11:10] - ASPM support)
191 ReadPCI (pciAddress + pcieCapOffset + 0x0D, AccWidthUint8, &value8);
193 value8 = (value8 >> 2) & (BIT1 + BIT0);
194 // Set ASPM state in link control register
195 RWPCI (pciAddress + pcieCapOffset + 0x10, AccWidthUint8, 0xffffffff, LxState & value8);
201 * sbGppSetEPAspm - Set EP GPP ASPM
204 * @param[in] pciAddress PCI Address.
205 * @param[in] LxState Lane State.
210 IN UINT32 pciAddress,
219 ReadPCI (pciAddress + 0x0E, AccWidthUint8, &value8);
222 maxFuncs = 8; // multi-function device
224 while (maxFuncs != 0) {
225 devBDF = pciAddress + (UINT32) ((maxFuncs - 1) << 16);
226 sbGppSetAspm (devBDF, LxState);
232 * sbGppValidateAspm - Validate endpoint support for GPP ASPM
235 * @param[in] pciAddress PCI Address.
236 * @param[in] LxState Lane State.
241 IN UINT32 pciAddress,
251 ReadPCI (pciAddress + 0x0E, AccWidthUint8, &value8);
254 maxFuncs = 8; // multi-function device
256 while (maxFuncs != 0) {
257 devBDF = pciAddress + (UINT32) ((maxFuncs - 1) << 16);
258 pcieCapOffset = sbFindPciCap (devBDF, PCIE_CAP_ID);
260 // Read link capabilities register (0x0C[11:10] - ASPM support)
261 ReadPCI (devBDF + pcieCapOffset + 0x0D, AccWidthUint8, &value8);
263 value8 = (value8 >> 2) & (BIT1 + BIT0);
264 // Set ASPM state as what's endpoint support
274 * sbGppForceGen2 - Set GPP to Gen2
277 * @param[in] pConfig Southbridge configuration structure pointer.
278 * @param[in] ActivePorts Activate Ports.
283 IN AMDSBCFG *pConfig,
284 IN CONST UINT8 ActivePorts
289 for ( portId = 0; portId < MAX_GPP_PORTS; portId++ ) {
290 if (ActivePorts & (1 << portId)) {
291 rwAlink (SB_RCINDXP_REGA4 | portId << 24, 0xFFFFFFFF, BIT29 + BIT0);
292 rwAlink ((SB_ABCFG_REG340 + portId * 4) | (UINT32) (ABCFG << 29), 0xFFFFFFFF, BIT21);
293 rwAlink (SB_RCINDXP_REGA2 | portId << 24, ~BIT13, 0);
294 rwAlink (SB_RCINDXP_REGC0 | portId << 24, ~BIT15, 0);
295 RWPCI (PCI_ADDRESS (0, GPP_DEV_NUM, portId, 0x88), AccWidthUint8, 0xf0, 0x02);
297 (&pConfig->PORTCONFIG[portId].PortCfg)->PortIsGen2 = 2;
303 * sbGppForceGen1 - Set GPP to Gen1
306 * @param[in] pConfig Southbridge configuration structure pointer.
307 * @param[in] ActivePorts Activate Ports.
312 IN AMDSBCFG *pConfig,
313 IN CONST UINT8 ActivePorts
318 for ( portId = 0; portId < MAX_GPP_PORTS; portId++ ) {
319 if (ActivePorts & (1 << portId) && pConfig->GppHardwareDowngrade != portId + 1) {
320 rwAlink ((SB_ABCFG_REG340 + portId * 4) | (UINT32) (ABCFG << 29), ~BIT21, 0);
321 rwAlink (SB_RCINDXP_REGA4 | portId << 24, ~BIT0, BIT29);
322 rwAlink (SB_RCINDXP_REGA2 | portId << 24, 0xFFFFFFFF, BIT13);
323 rwAlink (SB_RCINDXP_REGC0 | portId << 24, ~BIT15, 0);
324 RWPCI (PCI_ADDRESS (0, GPP_DEV_NUM, portId, 0x88), AccWidthUint8, 0xf0, 0x01);
326 (&pConfig->PORTCONFIG[portId].PortCfg)->PortIsGen2 = 1;
333 * PreInitGppLink - Enable GPP link training.
337 * @param[in] pConfig Southbridge configuration structure pointer.
345 UINT8 portMask[5] = {
357 // PCIE_GPP_ENABLE (abcfg:0xC0):
359 // GPP_LINK_CONFIG ([3:0]) PortA PortB PortC PortD Description
360 // ----------------------------------------------------------------------------------
361 // 0000 0-3 x4 Config
363 // 0010 0-1 2-3 0 2:2 Config
364 // 0011 0-1 2 3 2:1:1 Config
365 // 0100 0 1 2 3 1:1:1:1 Config
367 // For A12 and above:
368 // ABCFG:0xC0[12] - Port A hold training (default 1)
369 // ABCFG:0xC0[13] - Port B hold training (default 1)
370 // ABCFG:0xC0[14] - Port C hold training (default 1)
371 // ABCFG:0xC0[15] - Port D hold training (default 1)
375 // Set port enable bit fields based on current GPP link configuration mode
377 cfgMode = (UINT8) pConfig->GppLinkConfig;
378 if ( cfgMode > GPP_CFGMODE_X1111 || cfgMode == 1 ) {
379 cfgMode = GPP_CFGMODE_X4000;
380 pConfig->GppLinkConfig = GPP_CFGMODE_X4000;
382 reg32Value = (UINT32) portMask[cfgMode];
384 // Mask out non-applicable ports according to the target link configuration mode
385 for ( portId = 0; portId < MAX_GPP_PORTS; portId++ ) {
386 pConfig->PORTCONFIG[portId].PortCfg.PortPresent &= (reg32Value >> portId) & BIT0;
390 // Deassert GPP reset and pull EP out of reset - Clear GPP_RESET (abcfg:0xC0[8] = 0)
392 tmp16Value = (UINT16) (~reg32Value << 12);
393 reg32Value = (UINT32) (tmp16Value + (reg32Value << 4) + cfgMode);
394 writeAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29), reg32Value);
396 reg32Value = readAlink (0xC0 | (UINT32) (RCINDXC << 29));
397 writeAlink (0xC0 | (UINT32) (RCINDXC << 29), reg32Value | 0x400); // Set STRAP_F0_MSI_EN
399 // A-Link L1 Entry Delay Shortening
400 // AXINDP_Reg 0xA0[7:4] = 0x3
401 rwAlink (SB_AX_INDXP_REGA0, 0xFFFFFF0F, 0x30);
402 rwAlink (SB_AX_INDXP_REGB1, 0xFFFFFFFF, BIT19);
403 rwAlink (SB_AX_INDXP_REGB1, 0xFFFFFFFF, BIT28);
405 // RPR5.22 GPP L1 Entry Delay Shortening
406 // RCINDP_Reg 0xA0[7:4] = 0x1 Enter L1 sooner after ACK'ing PM request.
407 // This is done to reduce number of NAK received with L1 enabled.
408 // ENH254401: Program L0S/L1 activity timer to enable L0S/L1 on GPP
409 // RCINDP_Reg 0xA0[11:8] = 0x9
410 // RCINDP_Reg 0xA0[15:12] = 0x6
411 for ( portId = 0; portId < MAX_GPP_PORTS; portId++ ) {
412 rwAlink (SB_RCINDXP_REGA0 | portId << 24, 0xFFFF000F, 0x6910);
413 //OBS220313: Hard System Hang running MeatGrinder Test on multiple blocks
414 //RPR 5.13 GPP Error Reporting Configuration
415 rwAlink (SB_RCINDXP_REG6A | portId << 24, ~(BIT1), 0);
418 if (pConfig->S3Resume) {
419 SBGPPPORTCONFIG *portCfg;
421 for ( portId = 0; portId < MAX_GPP_PORTS; portId++ ) {
422 portCfg = &pConfig->PORTCONFIG[portId].PortCfg;
423 if (portCfg->PortHotPlug == TRUE) {
424 portCfg->PortDetected = FALSE;
426 if (portCfg->PortIsGen2 == 1) {
427 sbGppForceGen1 (pConfig, (UINT8) (1 << portId));
429 sbGppForceGen2 (pConfig, (UINT8) (1 << portId));
435 // Obtain original Gen2 strap value (LC_GEN2_EN_STRAP)
436 pConfig->GppGen2Strap = (UINT8) (readAlink (SB_RCINDXP_REGA4 | 0 << 24) & BIT0);
441 * GppPortPollingLtssm - Loop polling the LTSSM for each GPP port marked in PortMap
444 * Return: FailedPortMap = A bitmap of ports which failed to train
446 * @param[in] pConfig Southbridge configuration structure pointer.
447 * @param[in] ActivePorts A bitmap of ports which should be polled
448 * @param[in] IsGen2 TRUE if the polling is in Gen2 mode
452 GppPortPollingLtssm (
453 IN AMDSBCFG* pConfig,
454 IN UINT8 ActivePorts,
461 SBGPPPORTCONFIG *portCfg;
467 retryCounter = MAX_LT_POLLINGS;
468 EmptyPorts = ActivePorts;
470 while (retryCounter-- && ActivePorts) {
471 for (PortId = 0; PortId < MAX_GPP_PORTS; PortId++) {
472 if (ActivePorts & (1 << PortId)) {
473 portCfg = &pConfig->PORTCONFIG[PortId].PortCfg;
474 abIndex = SB_RCINDXP_REGA5 | (UINT32) (RCINDXP << 29) | (PortId << 24);
475 Data32 = readAlink (abIndex) & 0x3F3F3F3F;
477 if ((UINT8) (Data32) > 0x04) {
478 EmptyPorts &= ~(1 << PortId);
481 if ((UINT8) (Data32) == 0x10) {
482 ActivePorts &= ~(1 << PortId);
483 portCfg->PortDetected = TRUE;
489 for (i = 0; i < 4; i++) {
490 if ((UINT8) (Data32) == 0x29 || (UINT8) (Data32) == 0x2A ) {
491 ActivePorts &= ~(1 << PortId);
492 FailedPorts |= (1 << PortId);
500 if (EmptyPorts && retryCounter < (MAX_LT_POLLINGS - 200)) {
501 ActivePorts &= ~EmptyPorts;
505 FailedPorts |= ActivePorts;
511 * CheckGppLinkStatus - loop polling the link status for each GPP port
514 * Return: ToggleStatus[3:0] = Port bitmap for those need to clear De-emphasis
516 * @param[in] pConfig Southbridge configuration structure pointer.
526 UINT8 GppHwDowngrade;
527 SBGPPPORTCONFIG *portCfg;
534 // Obtain a list of ports to be checked
535 for ( portId = 0; portId < MAX_GPP_PORTS; portId++ ) {
536 portCfg = &pConfig->PORTCONFIG[portId].PortCfg;
537 if ( portCfg->PortPresent == TRUE && portCfg->PortDetected == FALSE ) {
538 portScanMap |= 1 << portId;
541 GppHwDowngrade = (UINT8)pConfig->GppHardwareDowngrade;
542 if (GppHwDowngrade != 0) {
543 // Skip polling and always assume this port to be present
544 portScanMap &= ~(1 << (GppHwDowngrade - 1));
547 //GPP Gen2 Speed Change
548 // if ((GPP Gen2 == enabled) and (RCINDP_Reg 0xA4[0] == 0x1)) {
549 // PCIe_Cfg 0x88[3:0] = 0x2
550 // RCINDP_Reg 0xA2[13] = 0x0
551 // RCINDP_Reg 0xC0[15] = 0x0
552 // RCINDP_Reg 0xA4[29] = 0x1
554 // PCIe_Cfg 0x88[3:0] = 0x1
555 // RCINDP_Reg 0xA4[0] = 0x0
556 // RCINDP_Reg 0xA2[13] = 0x1
557 // RCINDP_Reg 0xC0[15] = 0x0
558 // RCINDP_Reg 0xA4[29] = 0x1
561 if (pConfig->GppGen2 && pConfig->GppGen2Strap) {
562 sbGppForceGen2 (pConfig, portScanMap);
563 FailedPorts = GppPortPollingLtssm (pConfig, portScanMap, TRUE);
566 sbGppForceGen1 (pConfig, FailedPorts);
567 FailedPorts = GppPortPollingLtssm (pConfig, FailedPorts, FALSE);
570 sbGppForceGen1 (pConfig, portScanMap);
571 FailedPorts = GppPortPollingLtssm (pConfig, portScanMap, FALSE);
579 * - Search for display device behind each GPP port
580 * - If the port is empty AND not hotplug-capable:
581 * * Turn off link training
582 * * (optional) Power down the port
583 * * Hide the configuration space (Turn off the port)
585 * @param[in] pConfig Southbridge configuration structure pointer.
594 SBGPPPORTCONFIG *portCfg;
601 cimGppGen2 = pConfig->GppGen2;
602 #if SB_CIMx_PARAMETER == 0
603 cimGppGen2 = cimGppGen2Default;
606 pConfig->GppFoundGfxDev = 0;
607 abValue = readAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29));
608 //RPR 5.9 Link Bandwidth Notification Capability Enable
610 rwAlink (SB_RCINDXC_REGC1, 0xFFFFFFFF, BIT0);
612 for ( portId = 0; portId < MAX_GPP_PORTS; portId++ ) {
613 // Program requester ID for every port
614 abIndex = SB_RCINDXP_REG21 | (UINT32) (RCINDXP << 29) | (portId << 24);
615 writeAlink (abIndex, (SB_GPP_DEV << 3) + portId);
617 //RPR 5.9 Link Bandwidth Notification Capability Enable
618 //PCIe Cfg 0x68[10] = 0
619 //PCIe Cfg 0x68[11] = 0
620 RWPCI (PCI_ADDRESS (0, GPP_DEV_NUM, portId, 0x68), AccWidthUint16, ~(BIT10 + BIT11), 0);
622 portCfg = &pConfig->PORTCONFIG[portId].PortCfg;
623 // Check if there is GFX device behind each GPP port
624 if ( portCfg->PortDetected == TRUE ) {
625 regBusNumber = (SBTEMP_BUS << 16) + (SBTEMP_BUS << 8);
626 WritePCI (PCI_ADDRESS (0, GPP_DEV_NUM, portId, 0x18), AccWidthUint32, ®BusNumber);
628 ReadPCI (PCI_ADDRESS (SBTEMP_BUS, 0, 0, 0x0B), AccWidthUint8, &bValue);
630 pConfig->GppFoundGfxDev |= (1 << portId);
633 WritePCI (PCI_ADDRESS (0, GPP_DEV_NUM, portId, 0x18), AccWidthUint32, ®BusNumber);
634 } else if ( portCfg->PortPresent == FALSE || portCfg->PortHotPlug == FALSE ) {
635 // Mask off non-applicable ports
636 abValue &= ~(1 << (portId + 4));
639 if ( portCfg->PortHotPlug == TRUE ) {
640 // RPR5.12 Hot Plug: PCIe Native Support
641 // RCINDP_Reg 0x10[3] = 0x1
642 // PCIe_Cfg 0x5A[8] = 0x1
643 // PCIe_Cfg 0x6C[6] = 0x1
644 // RCINDP_Reg 0x20[19] = 0x0
645 rwAlink ((SB_RCINDXP_REG10 | (UINT32) (RCINDXP << 29) | (portId << 24)), 0xFFFFFFFF, BIT3);
646 RWPCI (PCI_ADDRESS (0, GPP_DEV_NUM, portId, 0x5b), AccWidthUint8, 0xff, BIT0);
647 RWPCI (PCI_ADDRESS (0, GPP_DEV_NUM, portId, 0x6c), AccWidthUint8, 0xff, BIT6);
648 rwAlink ((SB_RCINDXP_REG20 | (UINT32) (RCINDXP << 29) | (portId << 24)), ~BIT19, 0);
651 if ( pConfig->GppUnhidePorts == FALSE ) {
652 if ((abValue & 0xF0) == 0) {
653 abValue = BIT8; // if all ports are empty set GPP_RESET
654 } else if ((abValue & 0xE0) != 0 && (abValue & 0x10) == 0) {
655 abValue |= BIT4; // PortA should always be visible whenever other ports are exist
658 // Update GPP_Portx_Enable (abcfg:0xC0[7:5])
659 writeAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29), abValue);
663 // Common initialization for open GPP ports
665 for ( portId = 0; portId < MAX_GPP_PORTS; portId++ ) {
666 ReadPCI (PCI_ADDRESS (0, GPP_DEV_NUM, portId, 0x80), AccWidthUint8, &bValue);
667 if (bValue != 0xff) {
668 // Set pciCfg:PCIE_DEVICE_CNTL2[3:0] = 4'h6 (0x80[3:0])
671 WritePCI (PCI_ADDRESS (0, GPP_DEV_NUM, portId, 0x80), AccWidthUint8, &bValue);
673 // Set PCIEIND_P:PCIE_RX_CNTL[RX_RCB_CPL_TIMEOUT_MODE] (0x70:[19]) = 1
674 abIndex = SB_RCINDXP_REG70 | (UINT32) (RCINDXP << 29) | (portId << 24);
675 abValue = readAlink (abIndex) | BIT19;
676 writeAlink (abIndex, abValue);
678 // Set PCIEIND_P:PCIE_TX_CNTL[TX_FLUSH_TLP_DIS] (0x20:[19]) = 0
679 abIndex = SB_RCINDXP_REG20 | (UINT32) (RCINDXP << 29) | (portId << 24);
680 abValue = readAlink (abIndex) & ~BIT19;
681 writeAlink (abIndex, abValue);
683 // Set Immediate Ack PM_Active_State_Request_L1 (0xA0:[23]) = 0
684 abIndex = SB_RCINDXP_REGA0 | (UINT32) (RCINDXP << 29) | (portId << 24);
685 abValue = readAlink (abIndex) & ~BIT23;
686 if ( pConfig->L1ImmediateAck == 0) {
689 writeAlink (abIndex, abValue);
696 * sbPcieGppLateInit - Late PCIE initialization for Hudson-2 GPP component
699 * @param[in] pConfig Southbridge configuration structure pointer.
712 UINT8 cimGppPhyPllPowerDown;
713 SBGPPPORTCONFIG *portCfg;
716 // Disable hidden register decode and serial number capability
717 reg32Value = readAlink (SB_ABCFG_REG330 | (UINT32) (ABCFG << 29));
718 writeAlink (SB_ABCFG_REG330 | (UINT32) (ABCFG << 29), reg32Value & ~(BIT26 + BIT10));
720 if (readAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29)) & BIT8) {
727 // writeAlink (0xC0 | (UINT32) (RCINDXC << 29), 0x400); // Set STRAP_F0_MSI_EN
728 aspmValue = (UINT8)pConfig->GppPortAspm;
729 cimGppPhyPllPowerDown = (UINT8) pConfig->GppPhyPllPowerDown;
730 #if SB_CIMx_PARAMETER == 0
731 aspmValue = cimGppPortAspmDefault;
732 cimGppPhyPllPowerDown = cimGppPhyPllPowerDownDefault;
736 for ( portId = 0; portId < MAX_GPP_PORTS; portId++ ) {
737 // write pci_reg3d with 0x01 to fix yellow mark for GPP bridge under Vista
738 // when native PCIE is enabled but MSI is not available
739 // SB02029: Hudson-2 BIF/GPP allowing strap STRAP_BIF_INTERRUPT_PIN_SB controlled by AB reg
740 portCfg = &pConfig->PORTCONFIG[portId].PortCfg;
741 if (portCfg->PortHotPlug) {
742 RWPCI (PCI_ADDRESS (0, 21, portId, 0x04), AccWidthUint8, 0xFE, 0x00); //clear IO enable to fix possible hotplug hang
744 WritePCI (PCI_ADDRESS (0, 21, portId, 0x3d), AccWidthUint8, ®8Value);
745 ReadPCI (PCI_ADDRESS (0, 21, portId, 0x19), AccWidthUint8, &busNum);
746 if (busNum != 0xFF) {
747 ReadPCI (PCI_ADDRESS (busNum, 0, 0, 0x00), AccWidthUint32, ®32Value);
748 if (reg32Value != 0xffffffff) {
749 PortaspmValue = aspmValue;
750 // Vlidate if EP support ASPM
751 sbGppValidateAspm (PCI_ADDRESS (busNum, 0, 0, 0), &PortaspmValue);
752 // Set ASPM on EP side
753 sbGppSetEPAspm (PCI_ADDRESS (busNum, 0, 0, 0), PortaspmValue);
754 // Set ASPM on port side
755 sbGppSetAspm (PCI_ADDRESS (0, 21, portId, 0), PortaspmValue);
758 rwAlink ((SB_RCINDXP_REG02 | (UINT32) (RCINDXP << 29) | (portId << 24) ), ~(BIT15), (BIT15));
760 rwAlink ((SB_RCINDXC_REG02 | (UINT32) (RCINDXC << 29)), ~(BIT0), (BIT0));
763 // Configure Lock HWInit registers
765 reg32Value = readAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29));
766 if (reg32Value & 0xF0) {
767 reg32Value = readAlink (SB_RCINDXC_REG10 | (UINT32) (RCINDXC << 29));
768 writeAlink (SB_RCINDXC_REG10 | (UINT32) (RCINDXC << 29), reg32Value | BIT0); // Set HWINIT_WR_LOCK
770 if ( cimGppPhyPllPowerDown == TRUE ) {
772 // RPR 5.4 Power Saving Feature for GPP Lanes
776 // Set PCIE_P_CNTL in Alink PCIEIND space
777 abValue = readAlink (RC_INDXC_REG40 | (UINT32) (RCINDXC << 29));
778 abValue |= BIT12 + BIT3 + BIT0;
779 abValue &= ~(BIT9 + BIT4);
780 writeAlink (RC_INDXC_REG40 | (UINT32) (RCINDXC << 29), abValue);
781 rwAlink (SB_RCINDXC_REG02, ~(BIT8), (BIT8));
782 rwAlink (SB_RCINDXC_REG02, ~(BIT3), (BIT3));
786 // Restore strap0 via override
787 if (pConfig->PcieAER) {
788 rwAlink (SB_ABCFG_REG310 | (UINT32) (ABCFG << 29), 0xFFFFFFFF, BIT7);
789 rwAlink (RC_INDXC_REGC0, 0xFFFFFFFF, BIT9);
795 * sbGppDynamicPowerSaving - RPR 5.19 GPP Dynamic Power Saving
802 sbGppDynamicPowerSaving (
806 SBGPPPORTCONFIG *portCfg;
807 UINT8 cimGppLaneReversal;
808 UINT8 cimAlinkPhyPllPowerDown;
809 UINT8 cimGppPhyPllPowerDown;
814 if (!pConfig->GppDynamicPowerSaving || pConfig->sdbEnable) {
818 cimAlinkPhyPllPowerDown = (UINT8) pConfig->AlinkPhyPllPowerDown;
819 cimGppLaneReversal = (UINT8) pConfig->GppLaneReversal;
820 cimGppPhyPllPowerDown = (UINT8) pConfig->GppPhyPllPowerDown;
821 #if SB_CIMx_PARAMETER == 0
822 cimGppLaneReversal = cimGppLaneReversalDefault;
823 cimAlinkPhyPllPowerDown = cimAlinkPhyPllPowerDownDefault;
824 cimGppPhyPllPowerDown = cimGppPhyPllPowerDownDefault;
826 if (pConfig->GppHardwareDowngrade) {
827 portCfg = &pConfig->PORTCONFIG[pConfig->GppHardwareDowngrade - 1].PortCfg;
828 portCfg->PortDetected = TRUE;
833 switch ( pConfig->GppLinkConfig ) {
834 case GPP_CFGMODE_X4000:
835 portCfg = &pConfig->PORTCONFIG[0].PortCfg;
836 if ( portCfg->PortDetected == FALSE ) {
838 HoldData32 |= 0x1000;
841 case GPP_CFGMODE_X2200:
842 portCfg = &pConfig->PORTCONFIG[0].PortCfg;
843 if ( portCfg->PortDetected == FALSE ) {
844 Data32 |= ( cimGppLaneReversal )? 0x0c0c:0x0303;
845 HoldData32 |= 0x1000;
847 portCfg = &pConfig->PORTCONFIG[1].PortCfg;
848 if ( portCfg->PortDetected == FALSE ) {
849 Data32 |= ( cimGppLaneReversal )? 0x0303:0x0c0c;
850 HoldData32 |= 0x2000;
853 case GPP_CFGMODE_X2110:
854 portCfg = &pConfig->PORTCONFIG[0].PortCfg;
855 if ( portCfg->PortDetected == FALSE ) {
856 Data32 |= ( cimGppLaneReversal )? 0x0c0c:0x0303;
857 HoldData32 |= 0x1000;
859 portCfg = &pConfig->PORTCONFIG[1].PortCfg;
860 if ( portCfg->PortDetected == FALSE ) {
861 Data32 |= ( cimGppLaneReversal )? 0x0202:0x0404;
862 HoldData32 |= 0x2000;
864 portCfg = &pConfig->PORTCONFIG[2].PortCfg;
865 if ( portCfg->PortDetected == FALSE ) {
866 Data32 |= ( cimGppLaneReversal )? 0x0101:0x0808;
867 HoldData32 |= 0x4000;
870 case GPP_CFGMODE_X1111:
871 portCfg = &pConfig->PORTCONFIG[0].PortCfg;
872 if ( portCfg->PortDetected == FALSE ) {
873 Data32 |= ( cimGppLaneReversal )? 0x0808:0x0101;
874 HoldData32 |= 0x1000;
876 portCfg = &pConfig->PORTCONFIG[1].PortCfg;
877 if ( portCfg->PortDetected == FALSE ) {
878 Data32 |= ( cimGppLaneReversal )? 0x0404:0x0202;
879 HoldData32 |= 0x2000;
881 portCfg = &pConfig->PORTCONFIG[2].PortCfg;
882 if ( portCfg->PortDetected == FALSE ) {
883 Data32 |= ( cimGppLaneReversal )? 0x0202:0x0404;
884 HoldData32 |= 0x4000;
886 portCfg = &pConfig->PORTCONFIG[3].PortCfg;
887 if ( portCfg->PortDetected == FALSE ) {
888 Data32 |= ( cimGppLaneReversal )? 0x0101:0x0808;
889 HoldData32 |= 0x8000;
896 // RPR 5.11 Power Saving With GPP Disable
897 // ABCFG 0xC0[8] = 0x0
898 // ABCFG 0xC0[15:12] = 0xF
899 // Enable "Power Saving Feature for A-Link Express Lanes"
900 // Enable "Power Saving Feature for GPP Lanes"
901 // ABCFG 0x90[19] = 1
903 // RCINDC_Reg 0x65 [27:0] = 0xFFFFFFF
904 // ABCFG 0xC0[7:4] = 0x0
905 if ( cimAlinkPhyPllPowerDown && cimGppPhyPllPowerDown ) {
906 abValue = readAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29));
907 writeAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29), (( abValue | HoldData32 ) & (~ BIT8 )));
908 rwAlink (SB_AX_INDXC_REG40, ~(BIT9 + BIT4), (BIT0 + BIT3 + BIT12));
909 rwAlink ((SB_ABCFG_REG90 | (UINT32) (ABCFG << 29)), 0xFFFFFFFF, (BIT6 + BIT19));
910 rwAlink (RC_INDXC_REG65, 0xFFFFFFFF, ((Data32 & 0x0F) == 0x0F) ? Data32 | 0x0CFF0000 : Data32);
911 rwAlink (RC_INDXC_REG40, ~(BIT9 + BIT4), (BIT0 + BIT3 + BIT12));
917 * sbGppAerInitialization - Initializing AER
924 sbGppAerInitialization (
931 if (pConfig->PcieAER) {
932 // GPP strap configuration
933 rwAlink (SB_ABCFG_REG310 | (UINT32) (ABCFG << 29), ~(BIT7 + BIT4), BIT28 + BIT27 + BIT26 + BIT1);
934 rwAlink (SB_ABCFG_REG314 | (UINT32) (ABCFG << 29), ~(UINT32) (0xfff << 15), 0);
936 for (PortId = 0; PortId < MAX_GPP_PORTS; PortId++) {
937 ReadPCI (PCI_ADDRESS (0, GPP_DEV_NUM, PortId, 0x00), AccWidthUint32, &ValueDd);
938 if (ValueDd != 0xffffffff) {
939 rwAlink ((SB_RCINDXP_REG6A | (UINT32) (RCINDXP << 29) | (PortId << 24)), ~BIT1, 0);
940 rwAlink ((SB_RCINDXP_REG70 | (UINT32) (RCINDXP << 29) | (PortId << 24)), 0xFFFFE000, 0);
944 rwAlink (SB_RCINDXC_REG10, ~(BIT18 + BIT21 + BIT22), 0);
946 // AB strap configuration
947 rwAlink (SB_ABCFG_REGF0 | (UINT32) (ABCFG << 29), 0xFFFFFFFF, BIT15 + BIT14);
948 rwAlink (SB_ABCFG_REGF4 | (UINT32) (ABCFG << 29), 0xFFFFFFFF, BIT3);
950 // Enable GPP function0 error reporting
951 rwAlink (SB_ABCFG_REG310 | (UINT32) (ABCFG << 29), ~BIT7, BIT7);
952 rwAlink (SB_RCINDXC_REGC0, ~BIT9, BIT9);
954 //OBS220313: Hard System Hang running MeatGrinder Test on multiple blocks
955 //RPR 5.13 GPP Error Reporting Configuration
956 rwAlink (SB_ABCFG_REGF0 | (UINT32) (ABCFG << 29), ~(BIT1), 0);
957 //rwAlink (SB_ABCFG_REG310 | (UINT32) (ABCFG << 29), ~BIT7, 0);
958 //rwAlink (SB_RCINDXC_REGC0, ~BIT8, 0);
960 //RPR 5.13 GPP Error Reporting Configuration
961 rwAlink (SB_ABCFG_REGB8 | (UINT32) (ABCFG << 29), ~(BIT8 + BIT24 + BIT25 + BIT26 + BIT28), BIT8 + BIT24 + BIT26 + BIT28);
965 * sbGppRasInitialization - Initializing RAS
972 sbGppRasInitialization (
976 if (pConfig->PcieRAS) {
977 rwAlink (SB_ABCFG_REGF4 | (UINT32) (ABCFG << 29), 0xFFFFFFFF, BIT0);
983 //-----------------------------------------------------------------------------------
984 // Early Hudson-2 GPP initialization sequence:
986 // 1) Set port enable bit fields by current GPP link configuration mode
987 // 2) Deassert GPP reset and pull EP out of reset - Clear GPP_RESET (abcfg:0xC0[8] = 0)
988 // 3) Loop polling for the link status of all ports
989 // 4) Misc operations after link training:
990 // - (optional) Detect GFX device
991 // - Hide empty GPP configuration spaces (Disable empty GPP ports)
992 // - (optional) Power down unused GPP ports
993 // - (optional) Configure PCIE_P2P_Int_Map (abcfg:0xC4[7:0])
994 // 5) GPP init completed
998 // Gen2 mode Gen1 mode
999 // ---------------------------------------------------------------
1000 // STRAP_PHY_PLL_CLKF[6:0] 7'h32 7'h19
1001 // STRAP_BIF_GEN2_EN 1 0
1003 // PCIE_PHY_PLL clock locks @ 5GHz
1008 * GPP early programming and link training. On exit all populated EPs should be fully operational.
1012 * @param[in] pConfig Southbridge configuration structure pointer.
1016 sbPcieGppEarlyInit (
1017 IN AMDSBCFG* pConfig
1022 UINT8 cimGppMemWrImprove;
1023 UINT8 cimGppLaneReversal;
1024 UINT8 cimAlinkPhyPllPowerDown;
1027 cimNbSbGen2 = pConfig->NbSbGen2;
1028 cimGppMemWrImprove = pConfig->GppMemWrImprove;
1029 cimGppLaneReversal = (UINT8) pConfig->GppLaneReversal;
1030 cimAlinkPhyPllPowerDown = (UINT8) pConfig->AlinkPhyPllPowerDown;
1031 #if SB_CIMx_PARAMETER == 0
1032 cimNbSbGen2 = cimNbSbGen2Default;
1033 cimGppMemWrImprove = cimGppMemWrImproveDefault;
1034 cimGppLaneReversal = cimGppLaneReversalDefault;
1035 cimAlinkPhyPllPowerDown = cimAlinkPhyPllPowerDownDefault;
1040 // Configure NB-SB link PCIE PHY PLL power down for L1
1042 if ( cimAlinkPhyPllPowerDown == TRUE ) {
1043 // Set PCIE_P_CNTL in Alink PCIEIND space
1044 writeAlink (SB_AX_INDXC_REG30 | (UINT32) (AXINDC << 29), 0x40);
1045 abValue = readAlink (SB_AX_DATAC_REG34 | (UINT32) (AXINDC << 29));
1046 abValue |= BIT12 + BIT3 + BIT0;
1047 abValue &= ~(BIT9 + BIT4);
1048 writeAlink (SB_AX_DATAC_REG34 | (UINT32) (AXINDC << 29), abValue);
1049 rwAlink (SB_AX_INDXC_REG02 | (UINT32) (AXINDC << 29), ~(BIT8), (BIT8));
1050 rwAlink (SB_AX_INDXC_REG02 | (UINT32) (AXINDC << 29), ~(BIT3), (BIT3));
1053 // AXINDC_Reg 0xA4[18] = 0x1
1054 writeAlink (SB_AX_INDXP_REG38 | (UINT32) (AXINDP << 29), 0xA4);
1055 abValue = readAlink (SB_AX_DATAP_REG3C | (UINT32) (AXINDP << 29));
1057 writeAlink (SB_AX_DATAP_REG3C | (UINT32) (AXINDP << 29), abValue);
1061 // Set ABCFG 0x031C[0] = 1 to enable lane reversal
1063 reg32Value = readAlink (SB_ABCFG_REG31C | (UINT32) (ABCFG << 29));
1064 if ( cimGppLaneReversal ) {
1065 writeAlink (SB_ABCFG_REG31C | (UINT32) (ABCFG << 29), reg32Value | BIT0);
1067 writeAlink (SB_ABCFG_REG31C | (UINT32) (ABCFG << 29), reg32Value | 0x00);
1070 // Set abcfg:0x90[20] = 1 to enable GPP bridge multi-function
1072 reg32Value = readAlink (SB_ABCFG_REG90 | (UINT32) (ABCFG << 29));
1073 writeAlink (SB_ABCFG_REG90 | (UINT32) (ABCFG << 29), reg32Value | BIT20);
1077 // Initialize and configure GPP
1079 if (pConfig->GppFunctionEnable) {
1080 sbGppTogglePcieReset (pConfig);
1082 // PreInit - Enable GPP link training
1083 PreInitGppLink (pConfig);
1086 // GPP Upstream Memory Write Arbitration Enhancement ABCFG 0x54[26] = 1
1087 // GPP Memory Write Max Payload Improvement RCINDC_Reg 0x10[12:10] = 0x4
1089 if ( cimGppMemWrImprove == TRUE ) {
1090 rwAlink (SB_ABCFG_REG54 | (UINT32) (ABCFG << 29), ~BIT26, (BIT26));
1091 rwAlink (SB_RCINDXC_REG10 | (UINT32) (RCINDXC << 29), ~(BIT12 + BIT11 + BIT10), (BIT12));
1094 if (CheckGppLinkStatus (pConfig) && !pConfig->S3Resume) {
1095 // Toggle GPP reset (Note this affects all Hudson-2 GPP ports)
1096 sbGppTogglePcieReset (pConfig);
1099 // Misc operations after link training
1100 AfterGppLinkInit (pConfig);
1103 sbGppAerInitialization (pConfig);
1104 sbGppRasInitialization (pConfig);
1106 sbGppDynamicPowerSaving (pConfig);