1/*++
2
3Copyright (c)  1999  - 2014, Intel Corporation. All rights reserved
4
5  This program and the accompanying materials are licensed and made available under
6  the terms and conditions of the BSD License that accompanies this distribution.
7  The full text of the license may be found at
8  http://opensource.org/licenses/bsd-license.php.
9
10  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14
15Module Name:
16
17  HOST_BUS.ASL
18
19Abstract:
20
21  Baytrail PCI configuration space definition.
22
23---*/
24Device(VLVC)
25{
26  Name(_ADR, 0x00000000)           // Device 0, Function 0
27
28  // Define various MCH Controller PCI Configuration Space
29  // registers which will be used to dynamically produce all
30  // resources in the Host Bus _CRS.
31  OperationRegion(HBUS, PCI_Config, 0x00, 0xFF)
32  Field(HBUS, DWordAcc, NoLock, Preserve)
33  {
34    Offset(0xD0),
35    SMCR,   32,             // VLV Message Control Register (0xD0)
36    Offset(0xD4),
37    SMDR,   32,             // VLV Message Data Register (0xD4)
38    Offset(0xD8),
39    MCRX,   32,             // VLV Message Control Register Extension (0xD8)
40  }
41
42  // Define a method to read a 32-bit register on the VLV Message bus.
43  //  Arg0 = Port
44  //  Arg1 = Register
45  //
46  //  Returns 32-bit register value
47
48  Method(RMBR, 2, Serialized)
49  {
50
51    // Initiate regsiter read message on VLV Message Bus MCR
52
53    Or(ShiftLeft(Arg0, 16), ShiftLeft(Arg1, 8), Local0)
54    Or(0x100000F0, Local0, SMCR)
55
56    // Read register value from Message Data Register
57
58    Return(SMDR)
59  }
60
61
62  // Define a method to write a 32-bit register on the VLV Message bus MDR.
63  //  Arg0 = Port
64  //  Arg1 = Register
65  //  Arg2 = 32-bit value
66
67  Method(WMBR, 3, Serialized)
68  {
69
70    // Write register value to Message Data Register
71
72    Store(Arg2, SMDR)
73
74    // Initiate register write message on VLV Message Bus
75
76    Or(ShiftLeft(Arg0, 16), ShiftLeft(Arg1, 8), Local0)
77    Or(0x110000F0, Local0, SMCR)
78  }
79}
80
81//
82// BUS, I/O, and MMIO resources
83//
84Method(_CRS,0,Serialized)
85{
86  //Update ISP0 reserved memory
87  CreateDwordField(RES0, ^ISP0._MIN,ISMN)
88  CreateDwordField(RES0, ^ISP0._MAX,ISMX)
89  CreateDwordField(RES0, ^ISP0._LEN,ISLN)
90  If (LEqual(ISPD,1))
91  {
92    Store (ISPA, ISMN)
93    Add (ISMN, ISLN, ISMX)
94    Subtract(ISMX, 1, ISMX)
95  } Else
96  {
97    Store (0, ISMN)
98    Store (0, ISMX)
99    Store (0, ISLN)
100  }
101
102  //PCI MMIO SPACE
103  CreateDwordField(RES0, ^PM01._MIN,M1MN)
104  CreateDwordField(RES0, ^PM01._MAX,M1MX)
105  CreateDwordField(RES0, ^PM01._LEN,M1LN)
106
107  //Get dBMBOUND Base
108  And(BMBD, 0xFF000000, M1MN)
109
110  //Get ECBASE
111  Store(PCIT, M1MX)
112  Add(Subtract(M1MX, M1MN), 1, M1LN)
113  Subtract(M1MX, 1, M1MX)
114
115  // Create pointers to Gfx Stolen Memory Sizing values.
116  CreateDwordField(RES0, ^STOM._MIN,GSMN)
117  CreateDwordField(RES0, ^STOM._MAX,GSMX)
118  CreateDwordField(RES0, ^STOM._LEN,GSLN)
119
120  If (LNotEqual (\_SB.PCI0.GFX0.GSTM, 0xFFFFFFFF))
121  {
122    Store(0x00, GSMN) //Read the Stolen memory base from B0:D2:F0:R5C
123  } else
124  {
125    Store(\_SB.PCI0.GFX0.GSTM, GSMN) //Read the Stolen memory base from B0:D2:F0:R5C
126  }
127  If (LNotEqual (\_SB.PCI0.GFX0.GUMA, 0xFFFFFFFF))
128  {
129    Store(0x00, GSLN) //Read the Stolen memory base from B0:D2:F0:R5C
130  } else
131  {
132    ShiftLeft(\_SB.PCI0.GFX0.GUMA, 25, GSLN) //Read Stolen memory base form B0:D2:F0:R50
133  }
134  Add(GSMN, GSLN, GSMX) //Store the Stolen Memory Size
135  Subtract(GSMX, 1, GSMX)
136
137  Return(RES0)
138}
139
140Name( RES0,ResourceTemplate()
141{
142  WORDBusNumber (          // Bus number resource (0); the bridge produces bus numbers for its subsequent buses
143    ResourceProducer,      // bit 0 of general flags is 1
144    MinFixed,              // Range is fixed
145    MaxFixed,              // Range is fixed
146    PosDecode,             // PosDecode
147    0x0000,                // Granularity
148    0x0000,                // Min
149    0x00FF,                // Max
150    0x0000,                // Translation
151    0x0100                 // Range Length = Max-Min+1
152  )
153
154  IO (Decode16, 0x70, 0x77, 0x01, 0x08)         //Consumed resource (0xCF8-0xCFF)
155  IO (Decode16, 0xCF8, 0xCF8, 0x01, 0x08)       //Consumed resource (0xCF8-0xCFF)
156
157  WORDIO (                 // Consumed-and-produced resource (all I/O below CF8)
158    ResourceProducer,      // bit 0 of general flags is 0
159    MinFixed,              // Range is fixed
160    MaxFixed,              // Range is fixed
161    PosDecode,
162    EntireRange,
163    0x0000,                // Granularity
164    0x0000,                // Min
165    0x006F,                // Max
166    0x0000,                // Translation
167    0x0070                 // Range Length
168  )
169
170  WORDIO (                 // Consumed-and-produced resource
171    ResourceProducer,      // bit 0 of general flags is 0
172    MinFixed,              // Range is fixed
173    MaxFixed,              // Range is fixed
174    PosDecode,
175    EntireRange,
176    0x0000,                // Granularity
177    0x0078,                // Min
178    0x0CF7,                // Max
179    0x0000,                // Translation
180    0x0C80                 // Range Length
181  )
182
183  WORDIO (                 // Consumed-and-produced resource (all I/O above CFF)
184    ResourceProducer,      // bit 0 of general flags is 0
185    MinFixed,              // Range is fixed
186    MaxFixed,              // Range is fixed
187    PosDecode,
188    EntireRange,
189    0x0000,                // Granularity
190    0x0D00,                // Min
191    0xFFFF,                // Max
192    0x0000,                // Translation
193    0xF300                 // Range Length
194  )
195
196  DWORDMEMORY (            // Descriptor for legacy VGA video RAM
197    ResourceProducer,      // bit 0 of general flags is 0
198    PosDecode,
199    MinFixed,              // Range is fixed
200    MaxFixed,              // Range is fixed
201    Cacheable,
202    ReadWrite,
203    0x00000000,            // Granularity
204    0x000A0000,            // Min
205    0x000BFFFF,            // Max
206    0x00000000,            // Translation
207    0x00020000             // Range Length
208  )
209
210  DWORDMEMORY (            // Descriptor for legacy OptionRom
211    ResourceProducer,      // bit 0 of general flags is 0
212    PosDecode,
213    MinFixed,              // Range is fixed
214    MaxFixed,              // Range is fixed
215    Cacheable,
216    ReadWrite,
217    0x00000000,            // Granularity
218    0x000C0000,            // Min
219    0x000DFFFF,            // Max
220    0x00000000,            // Translation
221    0x00020000             // Range Length
222  )
223
224  DWORDMEMORY (            // Descriptor for BIOS Area
225    ResourceProducer,      // bit 0 of general flags is 0
226    PosDecode,
227    MinFixed,              // Range is fixed
228    MaxFixed,              // Range is fixed
229    Cacheable,
230    ReadWrite,
231    0x00000000,            // Granularity
232    0x000E0000,            // Min
233    0x000FFFFF,            // Max
234    0x00000000,            // Translation
235    0x00020000             // Range Length
236  )
237
238  DWORDMEMORY (            // Descriptor for ISP0 reserved Mem
239    ResourceProducer,      // bit 0 of general flags is 0
240    PosDecode,
241    MinFixed,              // Range is fixed
242    MaxFixed,              // Range is fixed
243    Cacheable,
244    ReadWrite,
245    0x00000000,            // Granularity
246    0x7A000000,            // Min
247    0x7A3FFFFF,            // Max
248    0x00000000,            // Translation
249    0x00400000             // Range Length
250    ,,,
251    ISP0
252  )
253
254  DWORDMEMORY (            // Descriptor for VGA Stolen Mem
255    ResourceProducer,      // bit 0 of general flags is 0
256    PosDecode,
257    MinFixed,              // Range is fixed
258    MaxFixed,              // Range is fixed
259    Cacheable,
260    ReadWrite,
261    0x00000000,            // Granularity
262    0x7C000000,            // Min
263    0x7FFFFFFF,            // Max
264    0x00000000,            // Translation
265    0x04000000             // Range Length
266    ,,,
267    STOM
268  )
269
270  DWORDMEMORY (            // Descriptor for PCI MMIO
271    ResourceProducer,      // bit 0 of general flags is 0
272    PosDecode,
273    MinFixed,              // Range is fixed
274    MaxFixed,              // Range is fixed
275    Cacheable,
276    ReadWrite,
277    0x00000000,            // Granularity
278    0x80000000,            // Min
279    0xDFFFFFFF,            // Max
280    0x00000000,            // Translation
281    0x60000000             // Range Length
282    ,,,
283    PM01
284  )
285})
286
287//Name(GUID,UUID("33DB4D5B-1FF7-401C-9657-7441C03DD766"))
288Name(GUID,Buffer()
289{
290  0x5b, 0x4d, 0xdb, 0x33,
291  0xf7, 0x1f,
292  0x1c, 0x40,
293  0x96, 0x57,
294  0x74, 0x41, 0xc0, 0x3d, 0xd7, 0x66
295})
296
297
298Name(SUPP,0)    // PCI _OSC Support Field value
299Name(CTRL,0)    // PCI _OSC Control Field value
300
301Method(_OSC,4,Serialized)
302{
303  // Check for proper UUID
304  // Save the capabilities buffer
305  Store(Arg3,Local0)
306
307  // Create DWord-adressable fields from the Capabilties Buffer
308  CreateDWordField(Local0,0,CDW1)
309  CreateDWordField(Local0,4,CDW2)
310  CreateDWordField(Local0,8,CDW3)
311
312  // Check for proper UUID
313  If(LAnd(LEqual(Arg0,GUID),NEXP))
314  {
315    // Save Capabilities DWord2 & 3
316    Store(CDW2,SUPP)
317    Store(CDW3,CTRL)
318
319    If(Not(And(CDW1,1)))    // Query flag clear?
320    {
321      // Disable GPEs for features granted native control.
322      If(And(CTRL,0x02))
323      {
324        NHPG()
325      }
326      If(And(CTRL,0x04))      // PME control granted?
327      {
328        NPME()
329      }
330    }
331
332    If(LNotEqual(Arg1,One))
333    {
334      // Unknown revision
335      Or(CDW1,0x08,CDW1)
336    }
337
338    If(LNotEqual(CDW3,CTRL))
339    {
340      // Capabilities bits were masked
341      Or(CDW1,0x10,CDW1)
342    }
343    // Update DWORD3 in the buffer
344	And(CTRL,0xfe,CTRL)
345    Store(CTRL,CDW3)
346    Store(CTRL,OSCC)
347    Return(Local0)
348  } Else
349  {
350    Or(CDW1,4,CDW1)         // Unrecognized UUID
351    Return(Local0)
352  }
353}       // End _OSC
354