Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 1 | /* 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 Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 9 | Device (LIEC) { |
| 10 | Name (_HID, "PURI4543") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 11 | Name (_UID, 0) |
| 12 | |
| 13 | Method (RSET, 0, Serialized) { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 14 | Printf ("LIEC: RSET") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 15 | SAPL(0) |
| 16 | SKBL(0) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | Method (INIT, 0, Serialized) { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 20 | Printf ("LIEC: INIT") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 21 | 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 Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 32 | Printf ("LIEC: FINI") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 33 | 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 Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 46 | If (^^PCI0.LPCB.EC0.WLED & 0x40) { |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 47 | 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 Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 57 | ^^PCI0.LPCB.EC0.WLED |= 0x40 |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 58 | } Else { |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 59 | ^^PCI0.LPCB.EC0.WLED &= 0xBF |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 64 | // Get notification red LED |
| 65 | Method (GNTR, 0, Serialized) { |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 66 | If (^^PCI0.LPCB.EC0.ECOK) { |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 67 | 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 DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 79 | // Get notification green LED |
| 80 | Method (GNTG, 0, Serialized) { |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 81 | If (^^PCI0.LPCB.EC0.ECOK) { |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 82 | 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 DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 91 | } |
| 92 | } |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 93 | |
| 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 DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 109 | // Get KB LED |
| 110 | Method (GKBL, 0, Serialized) { |
| 111 | Local0 = 0 |
| 112 | If (^^PCI0.LPCB.EC0.ECOK) { |
Felix Singer | ca4b587 | 2022-12-26 08:17:06 +0100 | [diff] [blame^] | 113 | ^^PCI0.LPCB.EC0.FDAT = 1 |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 114 | ^^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 DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 129 | |
| 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 | } |