summaryrefslogtreecommitdiff
path: root/Silicon/Socionext/SynQuacer/AcpiTables/AcpiSsdtRootPci.asl
blob: 24a3aa3a5bc23017cda98223113d6ca0b569963d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/** @file
  Secondary System Description Table (SSDT) for SynQuacer PCIe RCs

  Copyright (c) 2014-2016, ARM Ltd. All rights reserved.<BR>
  Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>

  This program and the accompanying materials are licensed and made available
  under the terms and conditions of the BSD License which accompanies this
  distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#include <Platform/Pcie.h>

#include "AcpiTables.h"

DefinitionBlock ("SsdtPci.aml", "SSDT", 1, "SNI", "SYNQUACR",
                 EFI_ACPI_OEM_REVISION)
{
  Scope (_SB)
  {
    Device (PCI0)
    {
        Name (_HID, EISAID("PNP0A08"))   // PCI Express Root Bridge
        Name (_CID, EISAID("PNP0A03"))   // Compatible PCI Root Bridge
        Name (_SEG, 0)                   // PCI Segment Group number
        Name (_BBN, Zero)                // PCI Base Bus Number
        Name (_CCA, 1)                   // Cache Coherency Attribute

        OperationRegion (BDF1, SystemMemory, SYNQUACER_PCI_SEG0_CONFIG_BASE, 0x10000)
        Field (BDF1, DWordAcc, NoLock, Preserve) {
            Offset (0x8000),
            VPID, 16,
        }

        Method (_STA, 0x0, Serialized) {
            //
            // Check whether the VID/PID of device #1 on bus #0 equals 0xffff.
            // If this is not the case, we are dealing with a ghost device,
            // which means we are running with outdated SCP firmware and we
            // should keep this PCIe RC disabled.
            //
            Store (VPID, local1)
            If (!LEqual (local1, 0xffff)) {
                Return (0x0)
            }
            Return (0xf)
        }

        // PCI Routing Table
        Name (_PRT, Package () {
            Package () { 0xFFFF, 0, Zero, 222 },   // INTA
            Package () { 0xFFFF, 1, Zero, 222 },   // INTB
            Package () { 0xFFFF, 2, Zero, 222 },   // INTC
            Package () { 0xFFFF, 3, Zero, 222 },   // INTD
        })
        // Root complex resources
        Method (_CRS, 0, Serialized) {
            Name (RBUF, ResourceTemplate () {
                WordBusNumber ( // Bus numbers assigned to this root
                    ResourceProducer,
                    MinFixed, MaxFixed, PosDecode,
                    0,                              // AddressGranularity
                    SYNQUACER_PCI_SEG0_BUSNUM_MIN,  // Minimum Bus Number
                    SYNQUACER_PCI_SEG0_BUSNUM_MAX,  // Maximum Bus Number
                    0,                              // AddressTranslation
                    SYNQUACER_PCI_SEG0_BUSNUM_RANGE // RangeLength - # of Busses
                )

                DWordMemory ( // 32-bit BAR Windows
                    ResourceProducer, PosDecode,
                    MinFixed, MaxFixed,
                    Cacheable, ReadWrite,
                    0x00000000,                         // Granularity
                    SYNQUACER_PCI_SEG0_MMIO32_MIN,      // Min Base Address
                    SYNQUACER_PCI_SEG0_MMIO32_MAX,      // Max Base Address
                    0x00000000,                         // Translate
                    SYNQUACER_PCI_SEG0_MMIO32_SIZE      // Length
                )

                QWordMemory ( // 64-bit BAR Windows
                    ResourceProducer, PosDecode,
                    MinFixed, MaxFixed,
                    Cacheable, ReadWrite,
                    0x00000000,                         // Granularity
                    SYNQUACER_PCI_SEG0_MMIO64_MIN,      // Min Base Address
                    SYNQUACER_PCI_SEG0_MMIO64_MAX,      // Max Base Address
                    0x00000000,                         // Translate
                    SYNQUACER_PCI_SEG0_MMIO64_SIZE      // Length
                )

                DWordIo ( // IO window
                    ResourceProducer,
                    MinFixed,
                    MaxFixed,
                    PosDecode,
                    EntireRange,
                    0x00000000,                         // Granularity
                    SYNQUACER_PCI_SEG0_PORTIO_MIN,      // Min Base Address
                    SYNQUACER_PCI_SEG0_PORTIO_MAX,      // Max Base Address
                    SYNQUACER_PCI_SEG0_PORTIO_MEMBASE,  // Translate
                    SYNQUACER_PCI_SEG0_PORTIO_MEMSIZE,  // Length
                    ,
                    ,
                    ,
                    TypeTranslation
                )
            }) // Name (RBUF)

            Return (RBUF)
        } // Method(_CRS)

        Device (RES0)
        {
            Name (_HID, "PNP0C02")
            Name (_CRS, ResourceTemplate ()
            {
                Memory32Fixed (ReadWrite,
                               SYNQUACER_PCI_SEG0_CONFIG_BASE,
                               SYNQUACER_PCI_SEG0_CONFIG_SIZE)
            })
        }

        //
        // OS Control Handoff
        //
        Name (SUPP, Zero) // PCI _OSC Support Field value
        Name (CTRL, Zero) // PCI _OSC Control Field value

        Method(_OSC,4)
        {
            // Check for proper UUID
            If (LEqual (Arg0, ToUUID ("33DB4D5B-1FF7-401C-9657-7441C03DD766")))
            {
                // Create DWord-adressable fields from the Capabilities Buffer
                CreateDWordField (Arg3, 0, CDW1)
                CreateDWordField (Arg3, 4, CDW2)
                CreateDWordField (Arg3, 8, CDW3)

                // Save Capabilities DWord2 & 3
                Store (CDW2, SUPP)
                Store (CDW3, CTRL)

                // Disable PCIe and SHPC hotplug, AER and PME
                And (CTRL, 0x10, CTRL)

                // Capabilities bits were masked
                Or (CDW1, 0x10, CDW1)

                // Update DWORD3 in the buffer
                Store (CTRL, CDW3)
                Return (Arg3)
            } Else {
                Or (CDW1, 4, CDW1) // Unrecognized UUID
                Return (Arg3)
            }
        } // End _OSC
    } // PCI0

    Device (PCI1)
    {
        Name (_HID, EISAID("PNP0A08"))   // PCI Express Root Bridge
        Name (_CID, EISAID("PNP0A03"))   // Compatible PCI Root Bridge
        Name (_SEG, 1)                   // PCI Segment Group number
        Name (_BBN, Zero)                // PCI Base Bus Number
        Name (_CCA, 1)                   // Cache Coherency Attribute

        OperationRegion (BDF1, SystemMemory, SYNQUACER_PCI_SEG1_CONFIG_BASE, 0x10000)
        Field (BDF1, DWordAcc, NoLock, Preserve) {
            Offset (0x8000),
            VPID, 16,
        }

        Method (_STA, 0x0, Serialized) {
            //
            // Check whether the VID/PID of device #1 on bus #0 equals 0xffff.
            // If this is not the case, we are dealing with a ghost device,
            // which means we are running with outdated SCP firmware and we
            // should keep this PCIe RC disabled.
            //
            Store (VPID, local1)
            If (!LEqual (local1, 0xffff)) {
                Return (0x0)
            }
            Return (0xf)
        }

        // PCI Routing Table
        Name (_PRT, Package () {
            Package () { 0xFFFF, 0, Zero, 214 },   // INTA
            Package () { 0xFFFF, 1, Zero, 214 },   // INTB
            Package () { 0xFFFF, 2, Zero, 214 },   // INTC
            Package () { 0xFFFF, 3, Zero, 214 },   // INTD
        })
        // Root complex resources
        Method (_CRS, 0, Serialized) {
            Name (RBUF, ResourceTemplate () {
                WordBusNumber ( // Bus numbers assigned to this root
                    ResourceProducer,
                    MinFixed, MaxFixed, PosDecode,
                    0,                              // AddressGranularity
                    SYNQUACER_PCI_SEG1_BUSNUM_MIN,  // Minimum Bus Number
                    SYNQUACER_PCI_SEG1_BUSNUM_MAX,  // Maximum Bus Number
                    0,                              // AddressTranslation
                    SYNQUACER_PCI_SEG1_BUSNUM_RANGE // RangeLength - # of Busses
                )

                DWordMemory ( // 32-bit BAR Windows
                    ResourceProducer, PosDecode,
                    MinFixed, MaxFixed,
                    Cacheable, ReadWrite,
                    0x00000000,                         // Granularity
                    SYNQUACER_PCI_SEG1_MMIO32_MIN,      // Min Base Address
                    SYNQUACER_PCI_SEG1_MMIO32_MAX,      // Max Base Address
                    0x00000000,                         // Translate
                    SYNQUACER_PCI_SEG1_MMIO32_SIZE      // Length
                )

                QWordMemory ( // 64-bit BAR Windows
                    ResourceProducer, PosDecode,
                    MinFixed, MaxFixed,
                    Cacheable, ReadWrite,
                    0x00000000,                         // Granularity
                    SYNQUACER_PCI_SEG1_MMIO64_MIN,      // Min Base Address
                    SYNQUACER_PCI_SEG1_MMIO64_MAX,      // Max Base Address
                    0x00000000,                         // Translate
                    SYNQUACER_PCI_SEG1_MMIO64_SIZE      // Length
                )

                DWordIo ( // IO window
                    ResourceProducer,
                    MinFixed,
                    MaxFixed,
                    PosDecode,
                    EntireRange,
                    0x00000000,                         // Granularity
                    SYNQUACER_PCI_SEG1_PORTIO_MIN,      // Min Base Address
                    SYNQUACER_PCI_SEG1_PORTIO_MAX,      // Max Base Address
                    SYNQUACER_PCI_SEG1_PORTIO_MEMBASE,  // Translate
                    SYNQUACER_PCI_SEG1_PORTIO_MEMSIZE,  // Length
                    ,
                    ,
                    ,
                    TypeTranslation
                )
            }) // Name (RBUF)

            Return (RBUF)
        } // Method(_CRS)

        Device (RES0)
        {
            Name (_HID, "PNP0C02")
            Name (_CRS, ResourceTemplate ()
            {
                Memory32Fixed (ReadWrite,
                               SYNQUACER_PCI_SEG1_CONFIG_BASE,
                               SYNQUACER_PCI_SEG1_CONFIG_SIZE)
            })
        }

        //
        // OS Control Handoff
        //
        Name (SUPP, Zero) // PCI _OSC Support Field value
        Name (CTRL, Zero) // PCI _OSC Control Field value

        Method(_OSC,4)
        {
            // Check for proper UUID
            If (LEqual (Arg0, ToUUID ("33DB4D5B-1FF7-401C-9657-7441C03DD766")))
            {
                // Create DWord-adressable fields from the Capabilities Buffer
                CreateDWordField (Arg3, 0, CDW1)
                CreateDWordField (Arg3, 4, CDW2)
                CreateDWordField (Arg3, 8, CDW3)

                // Save Capabilities DWord2 & 3
                Store (CDW2, SUPP)
                Store (CDW3, CTRL)

                // Disable PCIe and SHPC hotplug, AER and PME
                And (CTRL, 0x10, CTRL)

                // Capabilities bits were masked
                Or (CDW1, 0x10, CDW1)

                // Update DWORD3 in the buffer
                Store (CTRL, CDW3)
                Return (Arg3)
            } Else {
                Or (CDW1, 4, CDW1) // Unrecognized UUID
                Return (Arg3)
            }
        } // End _OSC
    } // PCI0
  }
}