Sean Rhodes | 296994b | 2021-10-14 20:58:15 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include "ubtc.asl" |
| 4 | |
| 5 | Scope (\_SB.PCI0.LPCB) |
| 6 | { |
| 7 | #include "cmos.asl" |
| 8 | |
| 9 | Device (EC) |
| 10 | { |
| 11 | Name (_HID, EisaId ("PNP0C09")) |
| 12 | Name (_UID, 0x01) |
Sean Rhodes | 58f6a5d | 2021-12-19 21:22:15 +0000 | [diff] [blame] | 13 | Name (_GPE, CONFIG_EC_GPE_SCI) |
Sean Rhodes | 296994b | 2021-10-14 20:58:15 +0100 | [diff] [blame] | 14 | Name (ECAV, 0x00) |
| 15 | Name (ECTK, 0x01) |
| 16 | Name (B2ST, 0x00) |
| 17 | Name (CFAN, 0x00) |
| 18 | Name (CMDR, 0x00) |
| 19 | Name (DOCK, 0x00) |
| 20 | Name (PLMX, 0x00) |
| 21 | Name (PECH, 0x00) |
| 22 | Name (PECL, 0x00) |
| 23 | Name (PENV, 0x00) |
| 24 | Name (PINV, 0x00) |
| 25 | Name (PPSH, 0x00) |
| 26 | Name (PPSL, 0x00) |
| 27 | Name (PSTP, 0x00) |
| 28 | Name (RPWR, 0x00) |
| 29 | Name (VPWR, 0x00) |
| 30 | Name (WTMS, 0x00) |
| 31 | Name (AWT2, 0x00) |
| 32 | Name (AWT1, 0x00) |
| 33 | Name (AWT0, 0x00) |
| 34 | Name (DLED, 0x00) |
| 35 | Name (SPT2, 0x00) |
| 36 | Name (PB10, 0x00) |
| 37 | Name (IWCW, 0x00) |
| 38 | Name (IWCR, 0x00) |
| 39 | Name (PVOL, 0x00) |
| 40 | Mutex (ECMT, 0x00) |
| 41 | |
Sean Rhodes | f6ea89d | 2022-02-24 10:40:57 +0000 | [diff] [blame] | 42 | Name (BFFR, ResourceTemplate() |
Sean Rhodes | 296994b | 2021-10-14 20:58:15 +0100 | [diff] [blame] | 43 | { |
| 44 | IO(Decode16, 0x0062, 0x0062, 0x00, 0x01) |
| 45 | IO(Decode16, 0x0066, 0x0066, 0x00, 0x01) |
| 46 | }) |
| 47 | |
| 48 | Method (_CRS, 0, Serialized) |
| 49 | { |
Sean Rhodes | f6ea89d | 2022-02-24 10:40:57 +0000 | [diff] [blame] | 50 | Return (BFFR) |
Sean Rhodes | 296994b | 2021-10-14 20:58:15 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | Method (_STA, 0, NotSerialized) |
| 54 | { |
| 55 | \LIDS = 0x03 |
| 56 | Return (0x0F) |
| 57 | } |
| 58 | |
| 59 | OperationRegion (SIPR, SystemIO, 0xB2, 0x1) |
| 60 | Field (SIPR, ByteAcc, Lock, Preserve) { |
| 61 | SMB2, 8 |
| 62 | } |
| 63 | |
| 64 | #include "emem.asl" |
| 65 | |
| 66 | // ECRD (Embedded Controller Read Method) |
| 67 | // |
| 68 | // Handle all commands sent to EC by BIOS |
| 69 | // |
| 70 | // Arguments: |
| 71 | // Arg0 = Object to Read |
| 72 | // |
| 73 | // Return Value: |
| 74 | // Read Value |
| 75 | // |
| 76 | Method (ECRD, 1, Serialized, 0, IntObj, FieldUnitObj) |
| 77 | { |
| 78 | // |
Felix Singer | ca4b587 | 2022-12-26 08:17:06 +0100 | [diff] [blame^] | 79 | // Check for ECDT support, set ECAV to 1 if ECDT is supported by OS |
Sean Rhodes | 296994b | 2021-10-14 20:58:15 +0100 | [diff] [blame] | 80 | // Only check once at beginning since ECAV might be clear later in certain conditions |
| 81 | // |
| 82 | If (ECTK) { |
| 83 | If (_REV >= 0x02) { |
| 84 | ECAV = 0x01 |
| 85 | } |
| 86 | ECTK = 0x00 // Clear flag for checking once only |
| 87 | } |
| 88 | |
| 89 | Local0 = Acquire (ECMT, 1000) // Save Acquired Result |
| 90 | If (Local0 == 0x00) // Check for Mutex Acquisition |
| 91 | { |
| 92 | If (ECAV) { |
| 93 | Local1 = DerefOf (Arg0) // Execute Read from EC |
| 94 | Release (ECMT) |
| 95 | Return (Local1) |
| 96 | } Else { |
| 97 | Release (ECMT) |
| 98 | } |
| 99 | } |
Sean Rhodes | f6ea89d | 2022-02-24 10:40:57 +0000 | [diff] [blame] | 100 | Return (0) // Return in case Arg0 doesn't exist |
Sean Rhodes | 296994b | 2021-10-14 20:58:15 +0100 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | // ECWR (Embedded Controller Write Method) |
| 104 | // |
| 105 | // Handle all commands sent to EC by BIOS |
| 106 | // |
| 107 | // Arguments: |
| 108 | // Arg0 = Value to Write |
| 109 | // Arg1 = Object to Write to |
| 110 | // |
| 111 | // Return Value: |
| 112 | // None |
| 113 | // |
| 114 | Method (ECWR, 2, Serialized,,,{IntObj, FieldUnitObj}) |
| 115 | { |
| 116 | Local0 = Acquire (ECMT, 1000) // Save Acquired Result |
| 117 | If (Local0 == 0x00) // Check for Mutex Acquisition |
| 118 | { |
| 119 | If (ECAV) { |
| 120 | Arg1 = Arg0 // Execute Write to EC |
| 121 | Local1 = 0x00 |
| 122 | While (1) { |
| 123 | If (Arg0 == DerefOf (Arg1)) { |
| 124 | Break |
| 125 | } |
| 126 | Sleep (1) |
| 127 | Arg1 = Arg0 |
Felix Singer | 26fbcc9 | 2021-12-30 01:48:51 +0100 | [diff] [blame] | 128 | Local1 += 1 |
Sean Rhodes | 296994b | 2021-10-14 20:58:15 +0100 | [diff] [blame] | 129 | If (Local1 == 0x03) { |
| 130 | Break |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | Release (ECMT) |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | #include "ac.asl" |
| 139 | #include "battery.asl" |
| 140 | #include "events.asl" |
| 141 | #include "lid.asl" |
| 142 | #include "typec.asl" |
| 143 | |
| 144 | Method (_REG, 2, NotSerialized) |
| 145 | { |
| 146 | If ((Arg0 == 0x03) && (Arg1 == 0x01)) |
| 147 | { |
| 148 | // Load EC Driver |
| 149 | ECAV = 0x01 |
| 150 | |
| 151 | // Initialise the Lid State |
| 152 | \LIDS = LSTE |
| 153 | |
| 154 | // Initialise the OS State |
| 155 | OSFG = 0x01 |
| 156 | |
| 157 | // Initialise the Power State |
| 158 | PWRS = (ECRD (RefOf(ECPS)) & 0x01) |
| 159 | |
| 160 | // Inform the platform code |
| 161 | PNOT() |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | } |