ec.asl 10.8 KB
Newer Older
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
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2007-2009 coresystems GmbH
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 of
 * the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

Device(EC0)
{
	Name (_HID, EISAID("PNP0C09"))
	Name (_UID, 1)

	Name (_GPE, 23)	// GPI07 / GPE23 -> Runtime SCI

	OperationRegion(ERAM, EmbeddedControl, 0x00, 0x37)
	Field (ERAM, ByteAcc, NoLock, Preserve)
	{
		MODE,	  1,	// Thermal Policy (Quiet/Perform)
		FAN,	  1,	// Fan Power (On/Off)
		LIDS, 	  1,	// LID Status (0=Open/1=Close)
		LSW0,	  1,	// LCD Power Switch

		BTYP,	  1,	// Battery Type (0=LiIon/1=NiMh)
		MWKE,	  1,	// Enable Wakeup from RI
		ADP,	  1,	// AC Adapter (0=Offline/1=Online)
		BAT,	  1,	// Battery (0=Not Present/1=Present)
		SLPT,	  3,	// Set Sleep Type on SLP enter (1=S1...4=S4)
		CHRG,	  1,	// 0=Battery not charging/1=Battery charging
		RI_W,	  1,	// Wake-up event source is RI
		KB_W,	  1,	// Wake-up event source is keyboard
		BATW,	  1,	// Wake-up event source is Battery Low
		PMEW,	  1,	// Wake-up event source is PME

		// Battery 0 Registers
		// Battery Life = BRC0/BPR0
		// Battery percentage = BRC0/BFC0 * 100
		BDC0,	 16,	// Designed Capacity
		BFC0,	 16,	// Last Full Charge Capacity
		BDV0,	 16,	// Design Voltage
		BPR0,	 16,	// Battery Present Rate
		BRC0,	 16,	// Battery Remaining Capacity
		BPV0,	 16,	// Battery Present Voltage

		Offset(0x11),
		CTMP,	  8,	// CPU Temperature
		Offset(0x15),
		CTRO,	  8,	// EC throttling on trip point
		CRTT,	  8,	// Critical Shut-down Temperature
		Offset(0x17),
		BKLL,	  8,	// Backlight Level

		// Battery 2 Registers
		Offset(0x20),
		,	  4,
		BTY2,	  1,	// Battery Type (0=LiIon/1=NiMh)
		,	  2,
		BAT2,	  1,	// Battery (0=Not Present/1=Present)
		,	  3,
		CRG2,	  1,	// 0=Battery not charging/1=Battery charging
		Offset(0x22),
		BDC2,	 16,	// Designed Capacity
		BFC2,	 16,	// Last Full Charge Capacity
		BDV2,	 16,	// Design Voltage
		BPR2,	 16,	// Battery Present Rate
		BRC2,	 16,	// Battery Remaining Capacity
		BPV2,	 16,	// Battery Present Voltage
		BTP2,	 16,	// Trip Point

		PBMO,	  2,	// PBMO power control method
		ECO,	  1,	// ECO on/off status
		SUN,	  1,	// Sunlight Readable
		RF,	  1,	// RF Enable/Disable status
		DOCK,	  1,	// Dock In/Out status
		CBAT,	  1,	// Car Battery status
		APPS,	  1,	// OSD utility status
		Offset(0x33),
		ODDS,	  1
	}

89
	Method (_CRS, 0, Serialized)
90 91 92 93 94 95 96 97 98 99 100 101 102
	{
		Name (ECMD, ResourceTemplate()
		{
			IO (Decode16, 0x62, 0x62, 1, 1)
			IO (Decode16, 0x66, 0x66, 1, 1)
		})

		Return (ECMD)
	}

	// EC Query methods, called upon SCI interrupts.
	Method (_Q01, 0)
	{
103
		Notify (\_PR.CP00, 0x80)
104 105 106 107 108 109 110 111 112 113 114 115 116 117
		If(ADP) {
			Store(1, \_SB.AC.ACST)
			TRAP(0xe3)
			Store(1, PWRS)
			TRAP(0x2b)
		} Else {
			Store(0, \_SB.AC.ACST)
			Notify(\_SB.AC, 0x80)
			Notify(\_SB.BAT0, 0x80)
			Store(0, PWRS)
			TRAP(0x2b)
		}

		PNOT()
118 119
		Notify(\_SB.BAT0, 0x80) // Execute BAT0 _BST
		Notify(\_SB.BAT1, 0x80) // Execute BAT1 _BST
120 121 122 123 124 125 126 127 128 129 130 131 132
	}

	Method (_Q02, 0)
	{
		If(BAT) {
			Notify(\_SB.BAT0, 0x00)
			Notify(\_SB.AC, 0x80)
		} Else {
			Notify(\_SB.AC, 0x80)
			Notify(\_SB.BAT0, 0x01)
		}

		PNOT()
133 134
		Notify(\_SB.BAT0, 0x80) // Execute BAT0 _BST
		Notify(\_SB.BAT1, 0x80) // Execute BAT1 _BST
135 136 137 138 139 140
	}

	Method (_Q05, 0)
	{
		Notify(SLPB, 0x80)
		PNOT()
141 142
		Notify(\_SB.BAT0, 0x80) // Execute BAT0 _BST
		Notify(\_SB.BAT1, 0x80) // Execute BAT1 _BST
143 144 145 146 147 148 149 150 151 152 153 154
	}

	Method (_Q07, 0)
	{
		TRAP(0xe0)

		If (LEqual(RTCF, 0x00)) {
			Notify(LID0, 0x80)
		} else {
			TRAP(0xc1)
		}
	}
Patrick Georgi's avatar
Patrick Georgi committed
155

156 157 158 159 160 161 162 163 164 165
	Method (_Q09, 0)
	{
		Notify(BAT0, 0x80)
		Notify(BAT1, 0x80)
	}

	Method (_Q0A, 0)
	{
		Notify(\_TZ.THRM, 0x80)
	}
Patrick Georgi's avatar
Patrick Georgi committed
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
	Method (_Q20, 0)
	{
		Notify(\_SB.ECO, 0x81)
	}

	Method (_Q21, 0)
	{
		Notify(\_SB.ECO, 0x82)
	}

	Method (_Q22, 0)
	{
		Notify(\_SB.ECO, 0x83)
	}

	Method (_Q23, 0)
	{
		Notify(\_SB.ECO, 0x84)
	}

	Method (_Q24, 0)
	{
		Store(0x3f, HOTK)
		If(IGDS) {
Vladimir Serbinenko's avatar
Vladimir Serbinenko committed
191
			Notify (\_SB.PCI0.GFX0, 0x82)
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
		} Else {
			TRAP(0xE1)
		}
		Notify (\_SB.ECO, 0x85)
	}

	Method (_Q25, 0)
	{
		Store(0x40, HOTK)
		TRAP(0xe1)
		Notify(\_SB.ECO, 0x86)
	}

	Method (_Q26, 0)
	{
		Store(0x41, HOTK)
		TRAP(0xe1)
		Notify(\_SB.ECO, 0x87)
	}

	Method (_Q27, 0)
	{
		Notify(\_SB.ECO, 0x88)
	}

	Method (_Q28, 0)
	{
		Notify(\_SB.ECO, 0x89)
	}

	Method (_Q29, 0)
	{
		Notify(\_SB.ECO, 0x8a)
	}

	Method (_Q2A, 0)
	{
		Store(0x57, HOTK)
		TRAP(0xe1)
		Notify(\_SB.ECO, 0x8b)
	}

	Method (_Q2B, 0)
	{
		Notify(SLPB, 0x80)
		Notify(\_SB.ECO, 0x8c)
	}

	Method (_Q2C, 0)
	{
		Store(0x59, HOTK)
		TRAP(0xe1)
	}

	Method (_Q38, 0)
	{
		// IDE TODO
	}

	Method (_Q39, 0)
	{
		// SATA TODO
	}

	Method (_Q3A, 0)
	{
		Store(1, BRTL)
		Notify(\_SB.ECO, 0x93)
	}

	Method (_Q3B, 0)
	{
		Store(0, BRTL)
		Notify(\_SB.ECO, 0x93)
	}

	Method (_Q3C, 0)
	{
		Store(1, SUN)
		Notify(\_SB.ECO, 0x92)
	}

	Method (_Q3D, 0)
	{
		Store(0, SUN)
		Notify(\_SB.ECO, 0x92)
	}

	/* Enable RF device */
	Method (_Q3E, 0)
	{
		TRAP(0xdf)
	}

	/* Disable RF device */
	Method (_Q3F, 0)
	{
		TRAP(0xc0)
	}

	/* ACBS LAN Power On */
	Method (_Q40, 0)
	{
		TRAP(0xd0)
		Sleep(500)
		Notify(RP04, 0)
	}

	/* ACBS LAN Power Off */
	Method (_Q41, 0)
	{
		TRAP(0xd1)
	}

	Method (_Q42, 0)
	{
		TRAP(0xf3)
	}

	Method (_Q43, 0)
	{
		TRAP(0xf4)
	}

	Method (_Q48, 0)
	{
		TRAP(0xd2) // Check AC Status
		Store (1, ODDS)
		Notify(\_SB.ECO, 0x90)
	}

	Method (_Q49, 0)
	{
		TRAP(0xd2) // Check AC Status
		Store (0, ODDS)
		Notify(\_SB.ECO, 0x90)
	}


	Method (_Q4C, 0)
	{
		Notify(\_SB.ECO, 0x94)
	}

	Method (_Q4D, 0)
	{
		Notify(\_SB.ECO, 0x95)
	}

	Method (_Q4E, 0)
	{
		// PATA TODO
	}

	Method (_Q4F, 0)
	{
		TRAP(0xf9)
		Notify(\_SB.ECO, 0x95)
	}

	Method (_Q5C, 0)
	{
		// Store(2, IGPS)
		Notify(\_SB.ECO, 0x94)
	}

	Method (_Q70, 0)
	{
		Notify(\_SB.ECO, 0x96)
	}

	Method (_Q71, 0)
	{
		Notify(\_SB.ECO, 0x97)
	}

	// TODO Scope _SB devices for AC power, LID, Power button
}

Scope(\_SB)
{
	/* This device is used by the GETAC P470 Windows drivers. */

	Device (ECO)
	{
		Name(_HID, "MTC0303") // MTC0303 BIOS Service Provider
		Method (GDPD, 0, Serialized)
		{
			// Set flag byte to zero
			Store (0, Local0)

			If (And(BRTL, 0x01)) {
				Or(Local0, 0x01, Local0)
			}

			If (And(BRTL, 0x02)) {
				Or(Local0, 0x04, Local0)
			}

			If (And(BRTL, 0x04)) {
				Or(Local0, 0x02, Local0)
			}

			If (And(BRTL, 0x30)) {
				Or(Local0, 0x10, Local0)
			}

			If (And(BRTL, 0x40)) {
				Or(Local0, 0x40, Local0)
			}

			Return (Local0)
		}

		Method (GDPC, 0, Serialized)
		{
			Store (0, Local0)

			If (And(BRTL, 0x10)) {
				Or(Local0, 0x04, Local0)
			}

			If (And( BRTL, 0x20)) {
				Or(Local0, 0x01, Local0)
			}

			If (And(BRTL, 0x40)) {
				Or(Local0, 0x02, Local0)
			}

			Return (Local0)
		}

		/* Set Brightness Level */
		Method(SBLL, 1, Serialized)
		{
			Store (Arg0, BRTL)
429
			TRAP(0xd5)	// See mainboard's smihandler.c
430 431 432 433 434 435
			Return (0)
		}

		/* Get Brightness Level */
		Method(GBLL, 0, Serialized)
		{
436
			TRAP(0xd6)	// See mainboard's smihandler.c
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 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
			Return (BRTL)
		}

		/* Get Brightness Level Medium? */
		Method(GBLM, 0, Serialized)
		{
			Store(0x3f, BRTL)
			// XXX don't we have to set the brightness?
			Return(BRTL)
		}

		/* ??? */
		Method(SUTE, 1, Serialized)
		{
			If (And(Arg0, 0x01)) {
				TRAP(0xf5)
			} Else {
				TRAP(0xf6)
			}
			Return (0)
		}

		/* ??? */
		Method(GECO, 0, Serialized)
		{
			TRAP(0xd7)
			Return (ODDS)
		}

		/* ??? */
		Method(GBSL, 0, Serialized)
		{
			TRAP(0xd8)
			Return (BRTL)
		}

		/* ??? Get LED/Device Enable Status */
		Method(GRFD, 0, Serialized)
		{
			/* Let coreboot update the flags */
			TRAP(0xe5)

			Store (0, Local0)
			If(And(RFDV, 0x01)) {
				Or(Local0, 0x01, Local0)
			}
			If(And(RFDV, 0x02)) {
				Or(Local0, 0x02, Local0)
			}
			If(And(RFDV, 0x02)) {
				Or(Local0, 0x02, Local0)
			}
			If(And(RFDV, 0x04)) {
				Or(Local0, 0x04, Local0)
			}
			If(And(RFDV, 0x08)) {
				Or(Local0, 0x08, Local0)
			}
495
			If(And(GP15, 0x01)) {		// GDIS
496 497
				Or(Local0, 0x10, Local0)
			}
498
			If(And(GP12, 0x01)) {		// WIFI Led (WLED)
499 500 501 502 503
				Or(Local0, 0x20, Local0)
			}
			If(And(BTEN, 0x01)) {		// BlueTooth Enable
				Or(Local0, 0x40, Local0)
			}
504
			If(And(GP10, 0x01)) {		// GPS Enable
505 506 507 508 509 510 511 512 513 514
				Or(Local0, 0x80, Local0)
			}

			Return (Local0)
		}

		/* Set RFD */
		Method(SRFD, 1, Serialized)
		{
			If (And(Arg0, 0x01)) {
515 516
				Store (1, GP14)		// GLED
				Store (1, GP15)		// GDIS
517
			} Else {
518
				Store (0, GP14)
519 520 521 522 523
				Store (0, GP15)
			}

			/* WIFI */
			If (And(Arg0, 0x02)) {
524 525
				Store (1, GP12)		// WLED
				Store (1, GP25)		// WLAN
526
			} Else {
527 528
				Store (0, GP12)
				Store (0, GP25)
529 530 531 532
			}

			/* Bluetooth */
			If (And(Arg0, 0x04)) {
533
				Store (1, GP13)		// BLED
534 535
				Store (1, BTEN)
			} Else {
536
				Store (0, GP13)		// BLED
537 538 539 540 541 542 543 544 545 546 547 548 549
				Store (0, BTEN)
			}
			Return (0)
		}

		/* Get DKD */
		Method(GDKD, 0, Serialized)
		{
			TRAP(0xd9)
			Return (BRTL)
		}

		/* Set DKD */
550
		Method(SDKD, 0, Serialized)
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
		{
			TRAP(0xda)
			Return (0)
		}

		/* Set IGD (Graphics) */
		Method(SIGD, 1, Serialized)
		{
			If (And(Arg0, 0x01)) {
				TRAP(0xf7)
			} Else {
				TRAP(0xf8)
			}
			Return (0)
		}

		/* SMI-C? Set Mic? */
		Method (SMIC, 1, Serialized)
		{
			If (And(Arg0, 0x01)) {
				TRAP(0xeb)
			} Else {
				TRAP(0xec)
			}
			Return (0)
		}

		/* ??? */
		Method(GTSD, 0, Serialized)
		{
581
			Return (GP19)	// TSDT
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
		}

		/* Not even decent function names anymore? */
		Method(S024, 1, Serialized)
		{
			If (And(Arg0, 0x01)) {
				TRAP(0xf1)
			} Else {
				TRAP(0xf2)
			}
			Return (0)
		}

		/* Get CVD */
		Method(GCVD, 0, Serialized)
		{
			TRAP(0xf9)
			Return (BRTL)
		}

		/* ??? Something with PATA */
		Method(S025, 1, Serialized)
		{
			If(And(Arg0, 0x01)) {
				TRAP(0xfc)

				Store (1, GP33)		// CREN
				Sleep(1500)

				Store (1, GP34)		// CRRS
				Sleep(500)

				Notify(^^PCI0.PATA, 0)
				Notify(^^PCI0.PATA.PRID, 0)
			} Else {
				TRAP(0xfb)
				Sleep(1500)
				Store(0, GP33)		// CREN
				Sleep(1500)
				Notify(^^PCI0.PATA, 0)
				Notify(^^PCI0.PATA.PRID, 0)
				Notify(^^PCI0.PATA.PRID.DSK1, 1)
				Notify(^^PCI0.PATA.PRID.DSK0, 1)
			}
			Return (0)
		}

		/* ??? */
		Method(G021, 0, Serialized)
		{
			TRAP(0xfe)
			If (LEqual(ACIN, 0)) {
				TRAP(0xfa)
				TRAP(0xfd)
				If (LEqual(ODDS, 1)) {
					TRAP(0xfb)
					Notify(^^PCI0.PATA, 0)
					Notify(^^PCI0.PATA.PRID.DSK1, 1)
					Notify(^^PCI0.PATA.PRID.DSK0, 1)
					Sleep (1500)
					Store (0, GP33)		// CREN
					Sleep (1500)
					Notify(^^PCI0.PATA, 0)
					Notify(^^PCI0.PATA.PRID.DSK1, 1)
					Notify(^^PCI0.PATA.PRID.DSK0, 1)
					Return (0)
				}
			}
			/* All Else Cases */
			Notify(ECO, 0xb1)
			Return (1)
		}

		/* Get RFS */
		Method(GRFS, 0, Serialized)
		{
			TRAP(0xff)
			Return(BRTL)
		}

		/* ??? */
		Method(S00B, 1, Serialized)
		{
			If (And(Arg0, 1)) {
				TRAP(0xdc)
			} Else {
				TRAP(0xdd)
			}
			Return (0)
		}
Patrick Georgi's avatar
Patrick Georgi committed
672 673


674 675 676

	}
}