| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
#define PCI_HOST_BRIDGE_OSC_UUID "33db4d5b-1ff7-401c-9657-7441c03dd766" |
| 4 |
#define CXL_HOST_BRIDGE_OSC_UUID "68f2d50b-c469-4d8a-bd3d-941a103fd3fc" |
| 5 |
|
| 6 |
#define OSC_RET_FAILURE 0x02 |
| 7 |
#define OSC_RET_UNRECOGNIZED_UUID 0x04 |
| 8 |
#define OSC_RET_UNRECOGNIZED_REV 0x08 |
| 9 |
#define OSC_RET_CAPABILITIES_MASKED 0x10 |
| 10 |
|
| 11 |
#define OSC_QUERY_SUPPORT_SET 0x01 |
| 12 |
|
| 13 |
#define ASL_UUID_UNHANDLED 0x00 |
| 14 |
#define ASL_UUID_HANDLED 0x01 |
| 15 |
|
| 16 |
Scope (\_SB) |
| 17 |
{ |
| 18 |
/* |
| 19 |
* \_SB.POSC - OSC handler for PCIe _OSC calls |
| 20 |
* |
| 21 |
* Reference: |
| 22 |
* 6.2.11 in https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/06_Device_Configuration/Device_Configuration.html |
| 23 |
* |
| 24 |
* Note: |
| 25 |
* This call negotiate with OS on fixed firmware capabilities. It doesn't support to runtime |
| 26 |
* change firmware settings. |
| 27 |
* |
| 28 |
* Arguments: (7) |
| 29 |
* Arg0 - Map to _OSC Arg0. A Buffer containing a UUID |
| 30 |
* Arg1 - Map to _OSC Arg1. An Integer containing a Revision ID of the buffer format |
| 31 |
* Arg2 - Map to _OSC Arg2. An Integer containing a count of entries in Arg3 |
| 32 |
* Arg3 - Map to _OSC Arg3. A Buffer containing a list of DWORD capabilities |
| 33 |
* Arg4 - GrantedPCIeFeatures |
| 34 |
* Arg5 - IsCxlDomain |
| 35 |
* Arg6 - GrantedCxlFeatures |
| 36 |
* |
| 37 |
* _OSC ASL Return Value: |
| 38 |
* A Buffer containing a list of capabilities |
| 39 |
* |
| 40 |
* Local Variables Assignment: |
| 41 |
* Local0 - Not used |
| 42 |
* Local1 - Not used |
| 43 |
* Local2 - Not used |
| 44 |
* Local3 - Not used |
| 45 |
* Local4 - Not used |
| 46 |
* Local5 - Not used |
| 47 |
* Local6 - Record whether the UUID is handled |
| 48 |
* Local7 - Backs up the input value of Arg3 |
| 49 |
* |
| 50 |
* Field Definitions: |
| 51 |
* Name - Width Source Offset Description |
| 52 |
* -------------------------------- |
| 53 |
* RETE - DWord Arg3 0x00 Returned errors |
| 54 |
* SUPP - Dword Arg3 0x04 PCIe Features that OS supported |
| 55 |
* CTRL - Dword Arg3 0x08 PCIe Features that firmware grant control to OS |
| 56 |
* OTRL - Dword Local7 0x08 PCIe Features that OS requests for control |
| 57 |
* SUPC - Dword Arg3 0x0C CXL Features that OS supported |
| 58 |
* CTRC - Dword Arg3 0x10 CXL Features that firmware grant control to OS |
| 59 |
* OTRC - Dword Local7 0x10 CXL Features that OS requests for control |
| 60 |
*/ |
| 61 |
|
| 62 |
Method (POSC, 7, NotSerialized) |
| 63 |
{ |
| 64 |
|
| 65 |
#define OscArg0 Arg0 |
| 66 |
#define OscArg1 Arg1 |
| 67 |
#define OscArg2 Arg2 |
| 68 |
#define OscArg3 Arg3 |
| 69 |
#define GrantedPCIeFeatures Arg4 |
| 70 |
#define IsCxlDomain Arg5 |
| 71 |
#define GrantedCxlFeatures Arg6 |
| 72 |
|
| 73 |
Local7 = OscArg3 |
| 74 |
CreateDWordField (OscArg3, Zero, RETE) |
| 75 |
RETE = 0x0 |
| 76 |
Local6 = ASL_UUID_UNHANDLED |
| 77 |
|
| 78 |
If ((OscArg1 != 0x01)) |
| 79 |
{ |
| 80 |
RETE = OSC_RET_UNRECOGNIZED_REV |
| 81 |
Return (OscArg3) |
| 82 |
} |
| 83 |
|
| 84 |
If ((OscArg2 < 0x03)) |
| 85 |
{ |
| 86 |
RETE = OSC_RET_FAILURE |
| 87 |
Return (OscArg3) |
| 88 |
} |
| 89 |
|
| 90 |
If ((OscArg0 == ToUUID (PCI_HOST_BRIDGE_OSC_UUID)) || |
| 91 |
((IsCxlDomain != 0x00) && |
| 92 |
(OscArg0 == ToUUID (CXL_HOST_BRIDGE_OSC_UUID)))) |
| 93 |
{ |
| 94 |
CreateDWordField (OscArg3, 0x04, SUPP) |
| 95 |
CreateDWordField (OscArg3, 0x08, CTRL) |
| 96 |
CreateDWordField (Local7, 0x08, OTRL) |
| 97 |
|
| 98 |
CTRL &= GrantedPCIeFeatures |
| 99 |
|
| 100 |
/* TODO: further suppress CTRL bits per SUPP caps */ |
| 101 |
|
| 102 |
If ((CTRL != OTRL)) |
| 103 |
{ |
| 104 |
RETE = OSC_RET_CAPABILITIES_MASKED |
| 105 |
} |
| 106 |
|
| 107 |
Local6 = ASL_UUID_HANDLED |
| 108 |
} |
| 109 |
|
| 110 |
If ((IsCxlDomain != 0x00) && |
| 111 |
(OscArg0 == ToUUID (CXL_HOST_BRIDGE_OSC_UUID))) |
| 112 |
{ |
| 113 |
CreateDWordField (OscArg3, 0x0C, SUPC) |
| 114 |
CreateDWordField (OscArg3, 0x10, CTRC) |
| 115 |
CreateDWordField (Local7, 0x10, OTRC) |
| 116 |
|
| 117 |
CTRC &= GrantedCxlFeatures |
| 118 |
|
| 119 |
/* TODO: further suppress CTRC bits per SUPC caps */ |
| 120 |
|
| 121 |
If ((CTRC != OTRC)) |
| 122 |
{ |
| 123 |
RETE = OSC_RET_CAPABILITIES_MASKED |
| 124 |
} |
| 125 |
|
| 126 |
Local6 = ASL_UUID_HANDLED |
| 127 |
} |
| 128 |
|
| 129 |
If ((Local6 == ASL_UUID_UNHANDLED)) |
| 130 |
{ |
| 131 |
RETE = OSC_RET_UNRECOGNIZED_UUID |
| 132 |
} |
| 133 |
|
| 134 |
Return (OscArg3) |
| 135 |
} |
| 136 |
} |