blob: 5f1e53d666837ce6ae0e72dd64174bba65624872 [file] [log] [blame]
Matt DeVillier7d57d562021-04-14 13:15:43 -05001/* SPDX-License-Identifier: GPL-2.0-only */
2
3// Notifications:
4// 0x80 - hardware backlight toggle
5// 0x81 - backlight toggle
6// 0x82 - backlight down
7// 0x83 - backlight up
8// 0x84 - backlight color change
Nicole Faerbere00ea2f2021-04-15 05:59:37 -05009Device (LIEC) {
10 Name (_HID, "PURI4543")
Matt DeVillier7d57d562021-04-14 13:15:43 -050011 Name (_UID, 0)
12
13 Method (RSET, 0, Serialized) {
Felix Singerdcebf6c2021-12-26 15:24:25 +010014 Printf ("LIEC: RSET")
Matt DeVillier7d57d562021-04-14 13:15:43 -050015 SAPL(0)
16 SKBL(0)
Matt DeVillier7d57d562021-04-14 13:15:43 -050017 }
18
19 Method (INIT, 0, Serialized) {
Felix Singerdcebf6c2021-12-26 15:24:25 +010020 Printf ("LIEC: INIT")
Matt DeVillier7d57d562021-04-14 13:15:43 -050021 RSET()
22 If (^^PCI0.LPCB.EC0.ECOK) {
23 // Set flags to use software control
24 ^^PCI0.LPCB.EC0.ECOS = 2
25 Return (0)
26 } Else {
27 Return (1)
28 }
29 }
30
31 Method (FINI, 0, Serialized) {
Felix Singerdcebf6c2021-12-26 15:24:25 +010032 Printf ("LIEC: FINI")
Matt DeVillier7d57d562021-04-14 13:15:43 -050033 RSET()
34 If (^^PCI0.LPCB.EC0.ECOK) {
35 // Set flags to use hardware control
36 ^^PCI0.LPCB.EC0.ECOS = 1
37 Return (0)
38 } Else {
39 Return (1)
40 }
41 }
42
43 // Get Airplane LED
44 Method (GAPL, 0, Serialized) {
45 If (^^PCI0.LPCB.EC0.ECOK) {
Nicole Faerbere00ea2f2021-04-15 05:59:37 -050046 If (^^PCI0.LPCB.EC0.WLED & 0x40) {
Matt DeVillier7d57d562021-04-14 13:15:43 -050047 Return (1)
48 }
49 }
50 Return (0)
51 }
52
53 // Set Airplane LED
54 Method (SAPL, 1, Serialized) {
55 If (^^PCI0.LPCB.EC0.ECOK) {
56 If (Arg0) {
Nicole Faerbere00ea2f2021-04-15 05:59:37 -050057 ^^PCI0.LPCB.EC0.WLED |= 0x40
Matt DeVillier7d57d562021-04-14 13:15:43 -050058 } Else {
Nicole Faerbere00ea2f2021-04-15 05:59:37 -050059 ^^PCI0.LPCB.EC0.WLED &= 0xBF
Matt DeVillier7d57d562021-04-14 13:15:43 -050060 }
61 }
62 }
63
Nicole Faerbere00ea2f2021-04-15 05:59:37 -050064 // Get notification red LED
65 Method (GNTR, 0, Serialized) {
Matt DeVillier7d57d562021-04-14 13:15:43 -050066 If (^^PCI0.LPCB.EC0.ECOK) {
Nicole Faerbere00ea2f2021-04-15 05:59:37 -050067 Return (^^PCI0.LPCB.EC0.NOTR)
68 }
69 Return (0)
70 }
71
72 // Set notification red LED
73 Method (SNTR, 1, Serialized) {
74 If (^^PCI0.LPCB.EC0.ECOK) {
75 ^^PCI0.LPCB.EC0.NOTR = Arg0
Matt DeVillier7d57d562021-04-14 13:15:43 -050076 }
77 }
78
Nicole Faerbere00ea2f2021-04-15 05:59:37 -050079 // Get notification green LED
80 Method (GNTG, 0, Serialized) {
Matt DeVillier7d57d562021-04-14 13:15:43 -050081 If (^^PCI0.LPCB.EC0.ECOK) {
Nicole Faerbere00ea2f2021-04-15 05:59:37 -050082 Return (^^PCI0.LPCB.EC0.NOTG)
83 }
84 Return (0)
85 }
86
87 // Set notification green LED
88 Method (SNTG, 1, Serialized) {
89 If (^^PCI0.LPCB.EC0.ECOK) {
90 ^^PCI0.LPCB.EC0.NOTG = Arg0
Matt DeVillier7d57d562021-04-14 13:15:43 -050091 }
92 }
Nicole Faerbere00ea2f2021-04-15 05:59:37 -050093
94 // Get notification blue LED
95 Method (GNTB, 0, Serialized) {
96 If (^^PCI0.LPCB.EC0.ECOK) {
97 Return (^^PCI0.LPCB.EC0.NOTB)
98 }
99 Return (0)
100 }
101
102 // Set notification blue LED
103 Method (SNTB, 1, Serialized) {
104 If (^^PCI0.LPCB.EC0.ECOK) {
105 ^^PCI0.LPCB.EC0.NOTB = Arg0
106 }
107 }
108
Matt DeVillier7d57d562021-04-14 13:15:43 -0500109 // Get KB LED
110 Method (GKBL, 0, Serialized) {
111 Local0 = 0
112 If (^^PCI0.LPCB.EC0.ECOK) {
Felix Singerca4b5872022-12-26 08:17:06 +0100113 ^^PCI0.LPCB.EC0.FDAT = 1
Matt DeVillier7d57d562021-04-14 13:15:43 -0500114 ^^PCI0.LPCB.EC0.FCMD = 0xCA
115 Local0 = ^^PCI0.LPCB.EC0.FBUF
116 ^^PCI0.LPCB.EC0.FCMD = Zero
117 }
118 Return (Local0)
119 }
120
121 // Set KB Led
122 Method (SKBL, 1, Serialized) {
123 If (^^PCI0.LPCB.EC0.ECOK) {
124 ^^PCI0.LPCB.EC0.FDAT = Zero
125 ^^PCI0.LPCB.EC0.FBUF = Arg0
126 ^^PCI0.LPCB.EC0.FCMD = 0xCA
127 }
128 }
Matt DeVillier7d57d562021-04-14 13:15:43 -0500129
130 // Fan names
131 Method (NFAN, 0, Serialized) {
132 Return (Package() {
133 "CPU fan",
134 })
135 }
136
137 // Get fan duty cycle and RPM as a single value
138 Method (GFAN, 1, Serialized) {
139 Local0 = 0
140 Local1 = 0
141 If (^^PCI0.LPCB.EC0.ECOK) {
142 If (Arg0 == 0) {
143 Local0 = ^^PCI0.LPCB.EC0.DUT1
144 Local1 = ^^PCI0.LPCB.EC0.RPM1
145 } ElseIf (Arg0 == 1) {
146 Local0 = ^^PCI0.LPCB.EC0.DUT2
147 Local1 = ^^PCI0.LPCB.EC0.RPM2
148 }
149 }
150 If (Local1 != 0) {
151 // 60 * (EC frequency / 120) / 2
152 Local1 = 2156250 / Local1
153 }
154 Return ((Local1 << 8) | Local0)
155 }
156
157 // Temperature names
158 Method (NTMP, 0, Serialized) {
159 Return (Package() {
160 "CPU temp",
161 })
162 }
163
164 // Get temperature
165 Method (GTMP, 1, Serialized) {
166 Local0 = 0;
167 If (^^PCI0.LPCB.EC0.ECOK) {
168 If (Arg0 == 0) {
169 Local0 = ^^PCI0.LPCB.EC0.TMP1
170 } ElseIf (Arg0 == 1) {
171 Local0 = ^^PCI0.LPCB.EC0.TMP2
172 }
173 }
174 Return (Local0)
175 }
176}