2 // This file is part of the coreboot project.
4 // Copyright (C) 2007 Advanced Micro Devices, Inc.
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; version 2 of the License.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 //AMD FAM10 util for BUSB and res range
26 Method (OSTP, 0, NotSerialized)
28 If (LEqual (^OSTB, Ones))
36 Method (SEQL, 2, Serialized)
38 Store (SizeOf (Arg0), Local0)
39 Store (SizeOf (Arg1), Local1)
40 If (LNot (LEqual (Local0, Local1))) { Return (Zero) }
42 Name (BUF0, Buffer (Local0) {})
44 Name (BUF1, Buffer (Local0) {})
47 While (LLess (Local2, Local0))
49 Store (DerefOf (Index (BUF0, Local2)), Local3)
50 Store (DerefOf (Index (BUF1, Local2)), Local4)
51 If (LNot (LEqual (Local3, Local4))) { Return (Zero) }
60 Method (DADD, 2, NotSerialized)
64 Add( ShiftLeft(Local1,16), Local0, Local0)
69 Method (GHCE, 1, NotSerialized) // check if the HC enabled
71 Store (DerefOf (Index (\_SB.PCI0.HCLK, Arg0)), Local1)
72 if(LEqual ( And(Local1, 0x01), 0x01)) { Return (0x0F) }
73 Else { Return (0x00) }
76 Method (GHCN, 1, NotSerialized) // get the node num for the HC
79 Store (DerefOf (Index (\_SB.PCI0.HCLK, Arg0)), Local1)
80 Store (ShiftRight( And (Local1, 0xfc), 0x02), Local0)
84 Method (GHCL, 1, NotSerialized) // get the link num on node for the HC
87 Store (DerefOf (Index (\_SB.PCI0.HCLK, Arg0)), Local1)
88 Store (ShiftRight( And (Local1, 0x700), 0x08), Local0)
92 Method (GHCD, 2, NotSerialized) // get the unit id base for the HT device in HC
95 Store (DerefOf (Index (\_SB.PCI0.HCDN, Arg0)), Local1)
96 Store (Arg1, Local2) // Arg1 could be 3, 2, 1, 0
97 Multiply (Local2, 0x08, Local2) // change to 24, 16, 8, 0
98 Store (And (ShiftRight( Local1, Local2), 0xff), Local0)
102 Method (GBUS, 2, NotSerialized)
105 While (LLess (Local0, 0x20)) // 32 ht links
107 Store (DerefOf (Index (\_SB.PCI0.BUSN, Local0)), Local1)
108 If (LEqual (And (Local1, 0x03), 0x03))
110 If (LEqual (Arg0, ShiftRight (And (Local1, 0xfc), 0x02)))
112 If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local1, 0x0700), 0x08))))
114 Return (ShiftRight (And (Local1, 0x000FF000), 0x0c))
125 Method (GWBN, 2, NotSerialized)
127 Name (BUF0, ResourceTemplate ()
129 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
130 0x0000, // Address Space Granularity
131 0x0000, // Address Range Minimum
132 0x0000, // Address Range Maximum
133 0x0000, // Address Translation Offset
136 CreateWordField (BUF0, 0x08, BMIN)
137 CreateWordField (BUF0, 0x0A, BMAX)
138 CreateWordField (BUF0, 0x0E, BLEN)
140 While (LLess (Local0, 0x20))
142 Store (DerefOf (Index (\_SB.PCI0.BUSN, Local0)), Local1)
143 If (LEqual (And (Local1, 0x03), 0x03))
145 If (LEqual (Arg0, ShiftRight (And (Local1, 0xfc), 0x02)))
147 If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local1, 0x0700), 0x08))))
149 Store (ShiftRight (And (Local1, 0x000FF000), 0x0c), BMIN)
150 Store (ShiftRight (Local1, 0x14), BMAX)
151 Subtract (BMAX, BMIN, BLEN)
164 Method (GMEM, 2, NotSerialized)
166 Name (BUF0, ResourceTemplate ()
168 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
169 0x00000000, // Address Space Granularity
170 0x00000000, // Address Range Minimum
171 0x00000000, // Address Range Maximum
172 0x00000000, // Address Translation Offset
174 , AddressRangeMemory, TypeStatic)
176 CreateDWordField (BUF0, 0x0A, MMIN)
177 CreateDWordField (BUF0, 0x0E, MMAX)
178 CreateDWordField (BUF0, 0x16, MLEN)
182 While (LLess (Local0, 0x80)) // 0x20 links * 2(mem, prefmem ) *2 ( base, limit )
184 Store (DerefOf (Index (\_SB.PCI0.MMIO, Local0)), Local1)
186 Store (DerefOf (Index (\_SB.PCI0.MMIO, Local0)), Local2)
187 If (LEqual (And (Local1, 0x03), 0x03))
189 If (LEqual (Arg0, And (Local2, 0x3f)))
191 If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local1, 0x70), 0x04))))
193 Store (ShiftLeft (And (Local1, 0xFFFFFF00), 0x08), MMIN)
194 Store (ShiftLeft (And (Local2, 0xFFFFFF00), 0x08), MMAX)
195 Or (MMAX, 0xFFFF, MMAX)
196 Subtract (MMAX, MMIN, MLEN)
201 Concatenate (RTAG (BUF0), Local3, Local5)
202 Store (Local5, Local3)
206 Store (RTAG (BUF0), Local3)
225 Method (GIOR, 2, NotSerialized)
227 Name (BUF0, ResourceTemplate ()
229 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
230 0x00000000, // Address Space Granularity
231 0x00000000, // Address Range Minimum
232 0x00000000, // Address Range Maximum
233 0x00000000, // Address Translation Offset
237 CreateDWordField (BUF0, 0x0A, PMIN)
238 CreateDWordField (BUF0, 0x0E, PMAX)
239 CreateDWordField (BUF0, 0x16, PLEN)
243 While (LLess (Local0, 0x40)) // 0x20 ht links * 2 ( base, limit)
245 Store (DerefOf (Index (\_SB.PCI0.PCIO, Local0)), Local1)
247 Store (DerefOf (Index (\_SB.PCI0.PCIO, Local0)), Local2)
248 If (LEqual (And (Local1, 0x03), 0x03))
250 If (LEqual (Arg0, And (Local2, 0x3f)))
252 If (LOr (LEqual (Arg1, 0xFF), LEqual (Arg1, ShiftRight (And (Local1, 0x70), 0x04))))
254 Store (And (Local1, 0x01FFF000), PMIN)
255 Store (And (Local2, 0x01FFF000), PMAX)
256 Or (PMAX, 0x0FFF, PMAX)
257 Subtract (PMAX, PMIN, PLEN)
262 Concatenate (RTAG (BUF0), Local3, Local5)
263 Store (Local5, Local3)
267 If (LGreater (PMAX, PMIN))
269 If (LOr (LAnd (LEqual (Arg1, 0xFF), LEqual (Arg0, 0x00)), LEqual (Arg1, \_SB.PCI0.SBLK)))
272 Subtract (PMAX, PMIN, PLEN)
276 Store (RTAG (BUF0), Local3)
280 If (And (Local1, 0x10))
288 Concatenate (RTAG (BUF0), Local3, Local5)
289 Store (Local5, Local3)
293 Store (RTAG (BUF0), Local3)
308 Store (RTAG (BUF0), Local3)
314 Method (RTAG, 1, NotSerialized)
317 Store (SizeOf (Local0), Local1)
318 Subtract (Local1, 0x02, Local1)
319 Multiply (Local1, 0x08, Local1)
320 CreateField (Local0, 0x00, Local1, RETB)