summaryrefslogtreecommitdiff
path: root/src/mainboard/roda/rk9/acpi/battery.asl
blob: 88e8aca4692dfd5f37e894ffda74e2b79986ce79 (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
/* SPDX-License-Identifier: GPL-2.0-only */

Name(\CBA1, 0x60)
Name(\CBA2, 0x60)

/* ACPI doesn't care if capacity is given in mWh or mAh,
   but it has to be consistent */

Device (BAT1)
{
	Name(_HID, EisaId("PNP0C0A"))
	Name(_UID, 1)

	Name(_PCL, Package(){ _SB })
	Name(PSTA, 0x1f)

	/* battery information */
	Name(PBIF, Package() {
		0x01,	// power unit
		0x01,	// design capacity (mWh/mAh), updated by UPBI
		0x01,	// last full charge capacity (mWh/mAh), updated by UPBI
		0x01,	// battery technology: "rechargeable"
		0x01,	// design voltage (mV), updated by UPBI
		0x0294,	// design capacity of warning (mWh/mAh)
		0x014a, // design capacity of low (mWh/mAh)
		0x42,	// battery capacity granularity between low and warning
		0x42,	// battery capacity granularity between warning and full
		"BAT1",	// Name
		"001 ",	// Number
		"LION",	// Type
		"JSE"	// Vendor
	})
	/* battery status */
	/* dummy values, filled in by UPBS */
	Name(PBST, Package() {
		0x00,	// battery state
			// bit0: discharging
			// bit1: charging
			// bit2: critical energy state
		0x01,	// battery present rate (mW/mA)
		0x01,	// remaining capacity (mW/mA)
		0x01	// battery present voltage (mV)
	})

	/* Status */
	Method(_STA, 0)
	{
		If(\_SB.PCI0.LPCB.EC0.ECON) {
			If(\_SB.PCI0.LPCB.EC0.B1PR) {
				If(\_SB.PCI0.LPCB.EC0.B1CH) {
					Return(0x1f)
				}
			}
		}
		Return(0x0f)
	}

	/* Battery Info */
	Method(_BIF, 0)
	{
		If(\_SB.PCI0.LPCB.EC0.ECON) {
			PBIF [1] = \_SB.PCI0.LPCB.EC0.B1DW
			PBIF [2] = \_SB.PCI0.LPCB.EC0.B1FW
			PBIF [4] = \_SB.PCI0.LPCB.EC0.B1DV
		}

		Return(PBIF)
	}

	/* Battery Status */
	Method(_BST, 0)
	{
		If(\_SB.PCI0.LPCB.EC0.ECON) {
			Local0 = \_SB.PCI0.LPCB.EC0.B1PW
			If (Local0 >= 0x8000) {
				Local0 = 0x10000 - Local0
			}
			PBST [1] = Local0
			PBST [3] = \_SB.PCI0.LPCB.EC0.B1PV

			PBST [2] = \_SB.PCI0.LPCB.EC0.B1RW

			If (\_SB.PCI0.LPCB.EC0.ACCH) {
				If (\_SB.PCI0.LPCB.EC0.B1CH) {
					If (\_SB.PCI0.LPCB.EC0.B1CG) {
						PBST [0] = 2
					}
				}
			} Else {
				If (\_SB.PCI0.LPCB.EC0.B1LO) {
					PBST [0] = 5
				} Else {
					PBST [0] = 1
				}
			}
		}

		Return(PBST)
	}

}

Device (BAT2)
{
	Name(_HID, EisaId("PNP0C0A"))
	Name(_UID, 2)

	Name(_PCL, Package(){ _SB })
	Name(PSTA, 0x1f)

	/* battery information */
	Name(PBIF, Package() {
		0x01,	// power unit
		0x01,	// design capacity (mWh/mAh), updated by UPBI
		0x01,	// last full charge capacity (mWh/mAh), updated by UPBI
		0x01,	// battery technology: "rechargeable"
		0x01,	// design voltage (mV), updated by UPBI
		0x0294,	// design capacity of warning (mWh/mAh)
		0x014a, // design capacity of low (mWh/mAh)
		0x42,	// battery capacity granularity between low and warning
		0x42,	// battery capacity granularity between warning and full
		"BAT1",	// Name
		"002 ",	// Number
		"LION",	// Type
		"JSE"	// Vendor
	})
	/* battery status */
	/* dummy values, filled in by UPBS */
	Name(PBST, Package() {
		0x00,	// battery state
			// bit0: discharging
			// bit1: charging
			// bit2: critical energy state
		0x01,	// battery present rate (mW/mA)
		0x01,	// remaining capacity (mW/mA)
		0x01	// battery present voltage (mV)
	})

	/* Status */
	Method(_STA, 0)
	{
		If(\_SB.PCI0.LPCB.EC0.ECON) {
			If(\_SB.PCI0.LPCB.EC0.B2PR) {
				If(\_SB.PCI0.LPCB.EC0.B2CH) {
					Return(0x1f)
				}
			}
		}
		Return(0x0f)
	}

	/* Battery Info */
	Method(_BIF, 0)
	{
		If(\_SB.PCI0.LPCB.EC0.ECON) {
			PBIF [1] = \_SB.PCI0.LPCB.EC0.B2DW
			PBIF [2] = \_SB.PCI0.LPCB.EC0.B2FW
			PBIF [4] = \_SB.PCI0.LPCB.EC0.B2DV
		}

		Return(PBIF)
	}

	/* Battery Status */
	Method(_BST, 0)
	{
		If(\_SB.PCI0.LPCB.EC0.ECON) {
			Local0 = \_SB.PCI0.LPCB.EC0.B2PW
			If (Local0 >= 0x8000) {
				Local0 = 0x10000 - Local0
			}
			PBST [1] = Local0
			PBST [3] = \_SB.PCI0.LPCB.EC0.B2PV

			PBST [2] = \_SB.PCI0.LPCB.EC0.B2RW

			If (\_SB.PCI0.LPCB.EC0.ACCH) {
				If (\_SB.PCI0.LPCB.EC0.B2CH) {
					If (\_SB.PCI0.LPCB.EC0.B2CG) {
						PBST [0] = 2
					}
				}
			} Else {
				If (\_SB.PCI0.LPCB.EC0.B2LO) {
					PBST [0] = 5
				} Else {
					PBST [0] = 1
				}
			}
		}

		Return(PBST)
	}

}

Device (ADP1)
{
	Name (_HID, "ACPI0003")
	Method (_PSR, 0)
	{
		PWRS = \_SB.PCI0.LPCB.EC0.ACCH
		Stall (0x02)
		Return (PWRS)
	}

	Method (_PCL, 0)
	{
		Return (_SB)
	}
}