summaryrefslogtreecommitdiff
path: root/src/ec/roda/it8518/acpi/ec.asl
blob: 94b00ce067cff6ac64a4c06b546de5459a174398 (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
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2015 secunet Security Networks AG
 *
 * 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.
 */

#include <drivers/pc80/pc/ps2_controller.asl>

Device (EC0)
{
	Name (_HID, EISAID ("PNP0C09"))		// ACPI Embedded Controller
	Name (_UID, 1)
	Name (_GPE, Add(EC_SCI_GPI, 16))	// GPE for Runtime SCI
	Name (PWRS, 1)
	Name (LIDS, 1)

	// EC RAM fields
	OperationRegion(ERAM, EmbeddedControl, 0, 0xFF)
	Field (ERAM, ByteAcc, NoLock, Preserve)
	{
		Offset(0x00),		// [Configuration Space 0x0]
		Offset(0x02),		// [Configuration Space 0x2]
		B0ST, 16,		// Battery 0 State
		B0FC, 16,		// Battery 0 Last Full Charge Capacity
		B0RC, 16,		// Battery 0 Remaining Capacity
		B0U1, 16,		// Unknown
		B0VT, 16,		// Battery 0 Present Voltage
		B0AC, 16,		// Battery 0 Present Rate
		Offset(0x40),		// [Configuration Space 0x40]
		ECOS, 8,		// OS System Type (0: DOS, 1: ACPI-compatible)
		CPUT, 8,		// CPU Temperature
		LOCT, 8,		// LOC Temperature
		OEMT, 8,		// OEM Temperature
		Offset (0x48),		// [Configuration Space 0x48]
		ECPS, 8,		// EC Power Source
		Offset (0x50),		// [Configuration Space 0x50]
		LUXH, 8,		// Ambient Light Illuminance High
		LUXL, 8,		// Ambient Light Illuminance Low
		Offset (0x5B),		// [Configuration Space 0x5B]
		BRIG, 8,		// Brightness
	} // End of ERAM

	Method (_STA, 0, NotSerialized)  // _STA: Status
	{
		Return (0x0F)
	}

	Method (_CRS, 0, NotSerialized)
	{
		Return (ResourceTemplate()
		{
			IO (Decode16, 0x62, 0x62, 0x00, 0x01)
			IO (Decode16, 0x66, 0x66, 0x00, 0x01)
		})
	}

	Method (_REG, 2, NotSerialized)
	{
		Store ("-----> EC: _REG", Debug)

		Store (0x01, ECOS)

		Store ("<----- EC: _REG", Debug)
	}

	Method (_Q29, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q29", Debug)

		Store (1, PWRS)
		Notify (AC, 0x80)
		Notify (AC, 0x00)
		Notify (BAT0, 0x00)
		Notify (BAT0, 0x80)

		Store ("<----- EC: _Q29", Debug)
	}

	Method (_Q31, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q31", Debug)

		Store (0, PWRS)
		Notify (AC, 0x80)
		Notify (AC, 0x00)
		Notify (BAT0, 0x00)
		Notify (BAT0, 0x80)

		Store ("<----- EC: _Q31", Debug)
	}

	Method (_Q32, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q32", Debug)

		Sleep (2500)
		Notify (BAT0, 0x00)
		Notify (BAT0, 0x80)
		Notify (BAT0, 0x81)
		Notify (BAT0, 0x82)

		Store ("<----- EC: _Q32", Debug)
	}

	Method (_Q33, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q33", Debug)

		Sleep (2500)
		Notify (BAT0, 0x00)
		Notify (BAT0, 0x80)
		Notify (BAT0, 0x81)
		Notify (BAT0, 0x82)

		Store ("<---- EC: _Q33", Debug)
	}

	Method (_Q36, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q36", Debug)

		Notify (BAT0, 0x80)

		Store ("<----- EC: _Q36", Debug)
	}

	Method (_Q37, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q37", Debug)

		Notify (BAT0, 0x80)

		Store ("<----- EC: _Q37", Debug)
	}

	Method (_Q43, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q43", Debug)

		Store (BRIG, Local0)
		Increment (Local0)
		If (LGreater (Local0, 0xAA)) {
			Store (0xAA, Local0)
		}
		Store (Local0, BRIG)

		\_SB.PCI0.GFX0.INCB ()

		Store ("<---- EC: _Q43", Debug)
	}

	Method (_Q44, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q44", Debug)

		Store (BRIG, Local0)
		Decrement (Local0)
		If (LLess (Local0, 0xA0))
		{
			Store (0xA0, Local0)
		}
		Store (Local0, BRIG)

		\_SB.PCI0.GFX0.DECB ()

		Store ("<---- EC: _Q44", Debug)
	}

	Method (_Q45, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q45", Debug)

		Store (0, LIDS)
		Notify (LID, 0x80)

		Store ("<----- EC: _Q45", Debug)
	}

	Method (_Q46, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q46", Debug)

		Store (1, LIDS)
		Notify (LID, 0x80)

		Store ("<----- EC: _Q46", Debug)
	}

	Method (_Q70, 0, NotSerialized)		// _Qxx: EC Query
	{
		Store ("-----> EC: _Q70", Debug)

		Notify (ALSD, 0x80)

		Store ("<----- EC: _Q70", Debug)
	}

	#include "battery.asl"
	#include "ac.asl"
	#include "lid.asl"
}