summaryrefslogtreecommitdiff
path: root/Core/EM/ACPI/Uart2ir.asl
blob: 5aa5b861858a044d598c3aef7a3db0218a2a2e59 (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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2009, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**             5555 Oakbrook Pkwy, Norcross, GA 30093               **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/Uart2ir.asl 7     3/26/09 4:53p Oleksiyy $
//
// $Revision: 7 $
//
// $Date: 3/26/09 4:53p $
//**********************************************************************;
// Revision History
// ----------------
// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Uart2ir.asl $
// 
// 7     3/26/09 4:53p Oleksiyy
// New ACPI Core implementation - improves logic, execution time and
// memory usage of ACPI module.
// 
// 6     4/09/08 5:05p Yakovlevs
// 
// 5     9/18/07 10:13a Pats
// Removed unnecessary decode range code.
// 
// 4     3/30/07 12:00p Pats
// Modified to support Fast IR.
// 
// 3     8/03/06 12:45p Stacyh
// Updated to allow the use of SI1P for systems with 2 SIOs.  Now contains
// generic methods assuming SI1P to be 0 as well as methods which check
// SI1P (these are commented out).
// 
// 2     4/03/06 4:05p Felixp
// New Super I/O infrastructure Support
// 
// 1     3/24/05 5:01p Sivagarn
// 
// 1     2/03/05 6:42p Sivagarn
// 0ABHI001 Check in
// 
// 1     7/27/04 2:48p Yakovlevs
// 
// 6     03/04/07 5:42p Chung
// Modify all I/O beta version
//
// 5	9/06/02 10:53a Alexp
// Add SourceSafe headers to all core asl files
//
//**********************************************************************;
// UART2 - COMB or Infrared //
// Requires Uart1(ir).asl component present as well
// Cannot be included along with UART2.ASL. Only one UART2 Device can be present in ASL.
// Category # :0x01
Device(UAR2)	// SMSC N207 UART 2.
{

OperationRegion(IOID,		// Name of Operation Region for SuperIO device
	SystemIO,		// Type of address space
	SP1O,			// Offset to start of region
	2)			// Size of region in bytes
				// End of Operation Region
Field(IOID, ByteAcc, NoLock,Preserve){
	INDX, 8,		// Field named INDX is 8 bit wide
	DATA, 8 		// Field DATA is 8 bit wide
}


//----------------------------------------------------------------------
//  Set of Field names to be used to access SIO configuration space.
//----------------------------------------------------------------------
IndexField(INDX, DATA, ByteAcc, NoLock, Preserve){
		Offset(0x02),
		CR02,	8, 	// UART Power Management
        Offset(0x0C),
        CR0C, 8,  // UARTMODE
		Offset(0x24),
		CR24,	8, 	// UART 1 Base Address
		CR25,	8, 	// UART 2 Base Address
		Offset(0x28),
		CR28,	8, 	// UART IRQ Select
		Offset(0x2B),
		CR2B,	8, 	// FIR Base address
		CR2C,	8, 	// FIR DMA
		Offset(0x3A),
		CR3A,	8, 	// LPC Docking Activate
		CR3B,	8, 	// LPC Docking Base (High)
		CR3C,	8, 	// LPC Docking Base (Low)
//		Offset(0x55),
//		CR55,	8, 	// Configuration Enable Key
//		Offset(0xAA),
//		CRAA,	8	// Configuration Disable Key
} //End of indexed field


//------------------------------------------------------------------------
// Entry Config Mode
//------------------------------------------------------------------------
Method(ENFG) {
	Store(0x55, INDX)
}


//------------------------------------------------------------------------
// Exit Config Mode
//------------------------------------------------------------------------
Method(EXFG, 0) {
	Store(0xAA, INDX)
}

    // Identify UART 2 as an IR Device.
	Name(_UID, 2)	//Generic ID for COMA
//	Name(_HID, EISAID("PNP0510"))

	Method(_HID, 0){
		ENFG()
		And(CR0C, 0x18, Local0)
		Store(CR2B, Local1)
		EXFG()
		If(Local0){
			If(Local1)
				{Return(EISAID("SMCF010"))}	//PnP Device ID FIR Type
			Else
				{Return(EISAID("PNP0510"))}	//PnP Device ID InfraRed Type
		}Else
			{Return(EISAID("PNP0501"))}	//PnP Device ID 16550 Type
	}


    // Status Method for UART 2.
    Method(_STA,0,Serialized)
    {
		//
		//Check SIR Base Address, If ADR9 and ADR8 are 0, SIR disabled.	
		//

		If(And(\IOST,0x02)){
			Return (0x0F)   // UART2 device Present
		} else {
			Return(0x00)	// Device not present
		}

	}

	// Disable Method for UART 2.
	Method(_DIS,0,Serialized)
	{
        ENFG()
		Store(And(CR02,0x0F),CR02)
        EXFG()
	}


  //
	// Current Resource Setting Method for UART 2.
  //
	Method(_CRS,0,Serialized)
	{

		ENFG()
		Store(CR2B, Local0)
		EXFG()
		If(Local0)
        {
    		// Create the FIR Buffer that stores the Resources to
    		// be returned.
    		Name(BUF0,ResourceTemplate()
    		{
        		IO(Decode16, 0x0000, 0x0000, 0x01, 0x08)
        		IO(Decode16, 0x0000, 0x0000, 0x01, 0x08)
        		IRQNoFlags() {7}
        		DMA(Compatibility, NotBusMaster, Transfer8, ) {2}
        	})

        	  // Create pointers to the specific byte.
              //
    	  	CreateByteField(BUF0,0x02,IO10)
    	  	CreateByteField(BUF0,0x03,IO11)
      		CreateByteField(BUF0,0x04,IO12)
    	  	CreateByteField(BUF0,0x05,IO13)
    	  	CreateByteField(BUF0,0x0a,IO20)
      		CreateByteField(BUF0,0x0b,IO21)
      		CreateByteField(BUF0,0x0c,IO22)
      		CreateByteField(BUF0,0x0d,IO23)
      	    CreateWordField(BUF0,0x11,IRQW)
   			CreateByteField(BUF0,0x14,DMA0)

            ENFG()
		
            //
		    // Write the Base Address into the Buffer.
            //
    		ShiftLeft(CR25,2,IO10)		// Low Byte.
            ShiftRight(And(CR25,0xC0), 6, IO11)
            Store(IO10, IO12)
            Store(IO11, IO13)

    		ShiftLeft(CR2B,3,IO20)		// Low Byte.
            ShiftRight(And(CR2B,0xE0), 5, IO21)
            Store(IO20, IO22)
            Store(IO21, IO23)

              //
    		  // Write the IRQ value into the Buffer.
              //
            Store(0x0,Local1)
            And(CR28,0x0F,Local1)
            ShiftLeft(1, Local1, IRQW)

            // Write DMA value into buffer
            Store(0x0,Local1)
            And(CR2C,0x0F,Local1)
    		If(LEqual(Local1, 0x0F)){
    			Store(0, DMA0)	//No DMA
    		}Else{
                ShiftLeft(1, Local1, DMA0)
    		}

            EXFG()

    		Return(BUF0)
        }
		Else 
        {
    		// Create the SIR Buffer that stores the Resources to
    		// be returned.
    		Name(BUF1,ResourceTemplate()
    		{
    			IO(Decode16,0x0000, 0x0000, 0x01, 0x08)
    			IRQNoFlags(){7}
        	})

        	  // Create pointers to the specific byte.
              //
    	  	CreateByteField(BUF1,0x02,IOL0)
      		CreateByteField(BUF1,0x03,IOL1)
    	  	CreateByteField(BUF1,0x04,IOL2)
      		CreateByteField(BUF1,0x05,IOL3)
      	    CreateWordField(BUF1,0x09,IRQR)
    
            ENFG()
		
            //
		    // Write the Base Address into the Buffer.
            //
    		ShiftLeft(CR25,2,IOL0)		// Low Byte.
            ShiftRight(And(CR25,0xC0), 6, IOL1)
            Store(IOL0, IOL2)
            Store(IOL0, IOL3)

              //
    		  // Write the IRQ value into the Buffer.
              //
            Store(0x0,Local1)
            And(CR28,0x0F,Local1)
            ShiftLeft(One,Local1,IRQR)

            EXFG()

    		Return(BUF1)
        }
	}

  //
	// Possible Resource Setting Method for UART 2.
  //
	Name(_PRS, ResourceTemplate() {
// IRQ, No DMA
	    	StartDependentFn(0, 0) 
            {
    			IO(Decode16,0x3E8,0x3E8,0x01,0x08) 
    			IRQNoFlags(){7}
    		}

			StartDependentFnNoPri()
			{
				IO(Decode16,0x2F8,0x2F8,0x01,0x08) 
    			IRQNoFlags() {3,4,5,6,7,10,11,12}
			}	

			StartDependentFnNoPri()
			{
				IO(Decode16,0x3F8,0x3F8,0x01,0x08) 
    			IRQNoFlags() {3,4,5,6,7,10,11,12}
			}	
	
			StartDependentFnNoPri()
			{
				IO(Decode16,0x2E8,0x2E8,0x01,0x08) 
    			IRQNoFlags() {3,4,5,6,7,10,11,12}
			}	

//IRA and DMA
		StartDependentFn(0, 0) {
   			IO(Decode16,0x3E8,0x3E8,0x01,0x08) 
			IO(Decode16,0x7E8,0x7E8,0x01,0x08)
   			IRQNoFlags(){7}
			DMA(Compatibility, NotBusMaster, Transfer8) {3}
		}
		StartDependentFnNoPri() {
			IO(Decode16, 0x3F8, 0x3F8, 1, 8)
			IO(Decode16,0x7E8,0x7E8,0x01,0x08)
			IRQNoFlags() {3,4,5,6,7,10,11,12}
			DMA(Compatibility, NotBusMaster, Transfer8) {1,2,3}
		}
		StartDependentFnNoPri() {
			IO(Decode16, 0x2F8, 0x3F8, 1, 8)
			IO(Decode16,0x7E8,0x7E8,0x01,0x08)
			IRQNoFlags() {3,4,5,6,7,10,11,12}
			DMA(Compatibility, NotBusMaster, Transfer8) {1,2,3}
		}
		StartDependentFnNoPri() {
			IO(Decode16, 0x3E8, 0x3E8, 1, 8)
			IO(Decode16,0x7E8,0x7E8,0x01,0x08)
			IRQNoFlags() {3,4,5,6,7,10,11,12}
			DMA(Compatibility, NotBusMaster, Transfer8) {1,2,3}
		}
		StartDependentFnNoPri() {
			IO(Decode16, 0x2E8, 0x3E8, 1, 8)
			IO(Decode16,0x7E8,0x7E8,0x01,0x08)
			IRQNoFlags() {3,4,5,6,7,10,11,12}
			DMA(Compatibility, NotBusMaster, Transfer8) {1,2,3}
		}
		EndDependentFn()
	})


	// Set Resource Setting Method for UART 2.
	Method(_SRS,1,Serialized)
	{
		ENFG()
		Store(CR2B, Local0)
		EXFG()
		If(Local0)
        {
    		// Point to the specific information in the passed
    		// in Buffer.
    	  	CreateByteField(Arg0,0x02,IO10)
      		CreateByteField(Arg0,0x03,IO11)
    	  	CreateByteField(Arg0,0x0a,IO20)
      		CreateByteField(Arg0,0x0b,IO21)
      	    CreateWordField(Arg0,0x11,IRQW)
   			CreateByteField(Arg0,0x14,DMA0)

            ENFG()

            //
    		// Disable the device.
            //
    		And(CR02,0x0F,CR02)

            //
            // Set UART2 mode
            //
//    		Store(0x0B, CR0C)		
//	    	Store(0x40, CR0A)		
//	    	Store(0x0C, CR0C)		

            //
    		// Set the Base IO Address.
            //
            Store(ShiftRight(IO10,2),CR25)
            Or(CR25,ShiftLeft(IO11,6),CR25)
			If(IO20){
                Store(ShiftRight(IO20,3),CR2B)
                Or(CR2B,ShiftLeft(IO21,5),CR2B)
			}


            //
     		// Set the IRQ.
            //
    		And(CR28,0xF0,CR28)
    		Or(CR28,Subtract(FindSetRightBit(IRQW),1),CR28)

            // Set DMA
            And(CR2C,0xF0,CR2C)
            If(DMA0)
            {
        		Or(CR2C,Subtract(FindSetRightBit(DMA0),1),CR2C)
            }
            Else
            {
        		Or(CR2C,0x0F,CR2C) // No DMA
            }

            //
    		// Enable the device.
            // 
    		Or(CR02,0x80,CR02)
        
            EXFG()

        }
        Else
        {
    		// Point to the specific information in the passed
    		// in Buffer.
    		CreateByteField(Arg0,0x02,IOLO)
    		CreateByteField(Arg0,0x03,IOHI)
    		CreateWordField(Arg0,0x09,IRQR)

            ENFG()

            //
    		// Disable the device.
            //
    		And(CR02,0x0F,CR02)

            //
            // Set UART2 mode
            //
//    		Store(0x0B, CR0C)		
//	    	Store(0x40, CR0A)		
//	    	Store(0x0C, CR0C)		

            //
    		// Set the Base IO Address.
            //
            Store(ShiftRight(IOLO,2),CR25)
            Or(CR25,ShiftLeft(IOHI,6),CR25)

            //
     		// Set the IRQ.
            //
    		And(CR28,0xF0,CR28)
    		Or(CR28,Subtract(FindSetRightBit(IRQR),1),CR28)

            //
    		// Enable the device.
            // 
    		Or(CR02,0x80,CR02)
        
            EXFG()
        }
   	}

    //
	// D0 Method for UART 2.
    //
	Method(_PS0,0,Serialized)
	{
        ENFG()
		Store(Or(CR02,0x80),CR02)
        EXFG()
	}



    //
	// D3 Method for UART 2.
    //
	Method(_PS3,0,Serialized)
	{
        ENFG()
		Store(And(CR02,0x0F),CR02)
        EXFG()
	}

}