summaryrefslogtreecommitdiff
path: root/src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibPciLib.esl
diff options
context:
space:
mode:
Diffstat (limited to 'src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibPciLib.esl')
-rw-r--r--src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibPciLib.esl289
1 files changed, 289 insertions, 0 deletions
diff --git a/src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibPciLib.esl b/src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibPciLib.esl
new file mode 100644
index 0000000000..378c0392ef
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibPciLib.esl
@@ -0,0 +1,289 @@
+/**
+ * @file
+ *
+ * ALIB ASL library
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 44324 $ @e \$Date: 2010-12-22 01:16:51 -0800 (Wed, 22 Dec 2010) $
+ *
+ */
+/*
+*****************************************************************************
+*
+* Copyright 2008 - 2012 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
+*
+* AMD is granting you permission to use this software (the Materials)
+* pursuant to the terms and conditions of your Software License Agreement
+* with AMD. This header does *NOT* give you permission to use the Materials
+* or any rights under AMD's intellectual property. Your use of any portion
+* of these Materials shall constitute your acceptance of those terms and
+* conditions. If you do not agree to the terms and conditions of the Software
+* License Agreement, please do not use any portion of these Materials.
+*
+* CONFIDENTIALITY: The Materials and all other information, identified as
+* confidential and provided to you by AMD shall be kept confidential in
+* accordance with the terms and conditions of the Software License Agreement.
+*
+* LIMITATION OF LIABILITY: THE MATERIALS AND ANY OTHER RELATED INFORMATION
+* PROVIDED TO YOU BY AMD ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED
+* WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
+* MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE,
+* OR WARRANTIES ARISING FROM CONDUCT, COURSE OF DEALING, OR USAGE OF TRADE.
+* IN NO EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER
+* (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS
+* INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF AMD'S NEGLIGENCE,
+* GROSS NEGLIGENCE, THE USE OF OR INABILITY TO USE THE MATERIALS OR ANY OTHER
+* RELATED INFORMATION PROVIDED TO YOU BY AMD, EVEN IF AMD HAS BEEN ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE
+* EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES,
+* THE ABOVE LIMITATION MAY NOT APPLY TO YOU.
+*
+* AMD does not assume any responsibility for any errors which may appear in
+* the Materials or any other related information provided to you by AMD, or
+* result from use of the Materials or any related information.
+*
+* You agree that you will not reverse engineer or decompile the Materials.
+*
+* NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make any
+* further information, software, technical information, know-how, or show-how
+* available to you. Additionally, AMD retains the right to modify the
+* Materials at any time, without notice, and is not obligated to provide such
+* modified Materials to you.
+*
+* U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with
+* "RESTRICTED RIGHTS." Use, duplication, or disclosure by the Government is
+* subject to the restrictions as set forth in FAR 52.227-14 and
+* DFAR252.227-7013, et seq., or its successor. Use of the Materials by the
+* Government constitutes acknowledgement of AMD's proprietary rights in them.
+*
+* EXPORT ASSURANCE: You agree and certify that neither the Materials, nor any
+* direct product thereof will be exported directly or indirectly, into any
+* country prohibited by the United States Export Administration Act and the
+* regulations thereunder, without the required authorization from the U.S.
+* government nor will be used for any purpose prohibited by the same.
+* ***************************************************************************
+*
+*/
+
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCI config register through MMIO
+ *
+ * Arg0 - PCI address Bus/device/func
+ * Arg1 - Register offset
+ */
+ Method (procPciDwordRead, 2, Serialized) {
+ Add (varPcieBase, ShiftLeft (Arg0, 12), Local0)
+ Add (Arg1, Local0, Local0)
+ OperationRegion(varOperationRegionMmio, SystemMemory, Local0, 0x4)
+ Field(varOperationRegionMmio, DWordAcc, NoLock, Preserve) {
+ Offset (0x0),
+ varPciReg32, 32,
+ }
+ return (varPciReg32)
+ }
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Write PCI config register through MMIO
+ *
+ * Arg0 - PCI address Bus/device/func
+ * Arg1 - Register offset
+ * Arg2 - Value
+ */
+ Method (procPciDwordWrite, 3, Serialized) {
+ Add (varPcieBase, ShiftLeft (Arg0, 12), Local0)
+ Add (Arg1, Local0, Local0)
+ OperationRegion(varOperationRegionMmio, SystemMemory, Local0, 0x4)
+ Field(varOperationRegionMmio, DWordAcc, NoLock, Preserve) {
+ Offset (0x0),
+ varPciReg32, 32,
+ }
+ Store (Arg2, varPciReg32)
+ }
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Write PCI config register through MMIO
+ *
+ * Arg0 - PCI address Bus/device/func
+ * Arg1 - Register offset
+ * Arg2 - AND mask
+ * Arg3 - OR mask
+ */
+ Method (procPciDwordRMW, 4, Serialized) {
+ Store (procPciDwordRead (Arg0, Arg1), Local0)
+ Or (And (Local0, Arg2), Arg3, Local0)
+ procPciDwordWrite (Arg0, Arg1, Local0)
+ }
+
+ Mutex(varPciePortAccessMutex, 0)
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCIe port indirect register
+ *
+ * Arg0 - Port Index
+ * Arg1 - Register offset
+ *
+ */
+ Method (procPciePortIndirectRegisterRead, 2, NotSerialized) {
+ Acquire(varPciePortAccessMutex, 0xFFFF)
+ Store (ShiftLeft (Add( Arg0, 2), 3), Local0)
+ procPciDwordWrite (Local0, 0xe0, Arg1)
+ Store (procPciDwordRead (Local0, 0xe4), Local0)
+ Release (varPciePortAccessMutex)
+ return (Local0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Write PCIe port indirect register
+ *
+ * Arg0 - Port Index
+ * Arg1 - Register offset
+ * Arg2 - Value
+ */
+ Method (procPciePortIndirectRegisterWrite, 3, NotSerialized) {
+ Acquire(varPciePortAccessMutex, 0xFFFF)
+ Store (ShiftLeft (Add( Arg0, 2), 3), Local0)
+ procPciDwordWrite (Local0, 0xe0, Arg1)
+ procPciDwordWrite (Local0, 0xe4, Arg2)
+ Release (varPciePortAccessMutex)
+ }
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCIe port indirect register
+ *
+ * Arg0 - Port Index
+ * Arg1 - Register offset
+ * Arg2 - AND Mask
+ * Arg3 - OR Mask
+ *
+ */
+ Method (procPciePortIndirectRegisterRMW, 4, NotSerialized) {
+ Store (procPciePortIndirectRegisterRead (Arg0, Arg1), Local0)
+ Or (And (Local0, Arg2), Arg3, Local0)
+ procPciePortIndirectRegisterWrite (Arg0, Arg1, Local0)
+ }
+ Mutex(varHostAccessMutex, 0)
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCIe port indirect register
+ *
+ * Arg0 - BDF
+ * Arg1 - Register offset
+ * Arg2 - Register address
+ *
+ */
+ Method (procIndirectRegisterRead, 3, NotSerialized) {
+ Acquire(varHostAccessMutex, 0xFFFF)
+ procPciDwordWrite (Arg0, Arg1, Arg2)
+ Store (procPciDwordRead (Arg0, Add (Arg1, 4)), Local0)
+ Release(varHostAccessMutex)
+ return (Local0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Write PCIe port indirect register
+ *
+ * Arg0 - BDF
+ * Arg1 - Register offset
+ * Arg2 - Register address
+ * Arg3 - Value
+ */
+ Method (procIndirectRegisterWrite, 4, NotSerialized) {
+ Acquire(varHostAccessMutex, 0xFFFF)
+ procPciDwordWrite (Arg0, Arg1, Arg2)
+ procPciDwordWrite (Arg0, Add (Arg1, 4), Arg3)
+ Release(varHostAccessMutex)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read Modify Write indirect registers
+ *
+ * Arg0 - BDF
+ * Arg1 - Register Offset
+ * Arg2 - Register Address
+ * Arg3 - AND Mask
+ * Arg4 - OR Mask
+ *
+ */
+ Method (procIndirectRegisterRMW, 5, NotSerialized) {
+ Store (procIndirectRegisterRead (Arg0, Arg1, Arg2), Local0)
+ Or (And (Local0, Arg3), Arg4, Local0)
+ procIndirectRegisterWrite (Arg0, Arg1, Arg2, Local0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Find Pci Capability
+ *
+ * Arg0 - PCI address Bus/device/func
+ * Arg1 - Capability id
+ */
+ Method (procFindPciCapability, 2, NotSerialized) {
+ Store (0x34, Local1)
+ if (LEqual (procPciDwordRead (Arg0, 0x0), 0xFFFFFFFF)) {
+ // Device not present
+ return (0)
+ }
+ Store (1, Local0)
+ while (LEqual (Local0, 1)) {
+ Store (And (procPciDwordRead (Arg0, Local1), 0xFF), Local1)
+ if (LEqual (Local1, 0)) {
+ break
+ }
+ if (LEqual (And (procPciDwordRead (Arg0, Local1), 0xFF), Arg1)) {
+ Store (0, Local0)
+ } else {
+ Increment (Local1)
+ }
+ }
+ return (Local1)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ *
+ *
+ * Arg0 - Aspm
+ * Arg1 - 0: Read, 1: Write
+ */
+ Method (procPcieSbAspmControl, 2, Serialized) {
+ // Create an opregion for PM IO Registers
+ OperationRegion (PMIO, SystemIO, 0xCD6, 0x2)
+ Field (PMIO, ByteAcc, NoLock, Preserve)
+ {
+ PMRI, 8,
+ PMRD, 8
+ }
+ IndexField (PMRI, PMRD, ByteAcc, NoLock, Preserve)
+ {
+ Offset(0xE0), // IO Base address of A-Link Express/ A-Link Bridge register
+ ABAR, 32,
+ }
+ OperationRegion (ACFG, SystemIO, ABAR, 0x8)
+ Field (ACFG, DWordAcc, Nolock, Preserve) //AB_INDX/AB_DATA
+ {
+ ABIX, 32,
+ ABDA, 32
+ }
+
+ Store (0, Local0)
+ if (LEqual (Arg1, 0)) {
+ Store (0x80000068, ABIX)
+ Store (ABDA, Local0)
+ return (Local0)
+ } else {
+ Store (0x80000068, ABIX)
+ Store (ABDA, Local0)
+ Or (And (Local0, 0xfffffffc), Arg0, Local0)
+ Store (Local0, ABDA)
+ }
+ }
+