Angel Pons | 210a008 | 2020-04-02 23:48:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 2 | |
| 3 | Device (EC0) |
| 4 | { |
| 5 | Name (_HID, EisaId ("PNP0C09")) |
| 6 | Name (_UID, 1) |
| 7 | Name (_GPE, EC_SCI_GPI) |
| 8 | Name (_STA, 0xf) |
Duncan Laurie | 4c14ca8 | 2018-11-20 17:27:47 -0800 | [diff] [blame] | 9 | Name (DBUG, Zero) |
Duncan Laurie | 3cd3cb6 | 2020-06-09 15:13:15 -0700 | [diff] [blame] | 10 | Name (ISSX, Zero) /* Is the EC in S0ix mode? */ |
| 11 | Name (UCEP, Zero) /* Is there a pending UCSI event? */ |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 12 | |
| 13 | Name (_CRS, ResourceTemplate() { |
| 14 | IO (Decode16, |
| 15 | CONFIG_EC_BASE_ACPI_DATA, |
| 16 | CONFIG_EC_BASE_ACPI_DATA, |
| 17 | 4, 4) |
| 18 | IO (Decode16, |
| 19 | CONFIG_EC_BASE_ACPI_COMMAND, |
| 20 | CONFIG_EC_BASE_ACPI_COMMAND, |
| 21 | 4, 4) |
| 22 | }) |
| 23 | |
| 24 | /* Handle registration of EmbeddedControl region */ |
| 25 | Name (EREG, Zero) |
| 26 | OperationRegion (ERAM, EmbeddedControl, 0, 0xff) |
| 27 | Method (_REG, 2) |
| 28 | { |
| 29 | /* Indicate region is registered */ |
| 30 | EREG = Arg1 |
| 31 | |
| 32 | /* Store initial value for power status */ |
Duncan Laurie | a213ed6 | 2019-02-21 17:38:03 -0800 | [diff] [blame] | 33 | ECPR = R (PWSR) |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 34 | |
| 35 | /* Indicate to EC that OS is ready for queries */ |
Duncan Laurie | 4c14ca8 | 2018-11-20 17:27:47 -0800 | [diff] [blame] | 36 | W (ERDY, Arg1) |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 37 | |
Duncan Laurie | 286a0ab | 2019-01-25 10:28:03 -0800 | [diff] [blame] | 38 | /* Indicate that the OS supports S0ix */ |
Felix Singer | ca4b587 | 2022-12-26 08:17:06 +0100 | [diff] [blame^] | 39 | W (CSOS, 1) |
Duncan Laurie | 286a0ab | 2019-01-25 10:28:03 -0800 | [diff] [blame] | 40 | |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 41 | /* Tell EC to stop emulating PS/2 mouse */ |
| 42 | W (PS2M, Zero) |
Duncan Laurie | 98d7de7 | 2018-11-20 17:30:47 -0800 | [diff] [blame] | 43 | |
| 44 | /* Enable DPTF support if enabled in devicetree */ |
Felix Singer | ca4b587 | 2022-12-26 08:17:06 +0100 | [diff] [blame^] | 45 | If (\DPTE == 1) { |
Duncan Laurie | 98d7de7 | 2018-11-20 17:30:47 -0800 | [diff] [blame] | 46 | W (DWST, Arg1) |
| 47 | } |
Duncan Laurie | c145e54 | 2019-04-18 16:37:50 -0700 | [diff] [blame] | 48 | |
| 49 | /* Initialize UCSI */ |
| 50 | ^UCSI.INIT () |
Eric Lai | 5ddce58 | 2020-03-13 17:42:03 +0800 | [diff] [blame] | 51 | |
| 52 | // Initialize LID switch state |
Elyes HAOUAS | 2a08ca7 | 2020-10-06 18:05:05 +0200 | [diff] [blame] | 53 | \LIDS = R (P1LC) |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /* |
| 57 | * Find bitmask for field |
| 58 | * Arg0 = EC field structure |
| 59 | * Arg1 = Value |
| 60 | */ |
| 61 | Method (EBIT, 2, NotSerialized) |
| 62 | { |
| 63 | Local0 = DeRefOf (Arg0[1]) /* Mask */ |
| 64 | Local1 = Arg1 & Local0 |
| 65 | FindSetRightBit (Local0, Local2) |
| 66 | If (Local2) { |
| 67 | Local1 >>= Local2 - 1 |
| 68 | } |
| 69 | Return (Local1) |
| 70 | } |
| 71 | |
| 72 | /* |
| 73 | * READ or WRITE from EC region |
| 74 | * Arg0 = EC field structure |
| 75 | * Arg1 = Value to write |
| 76 | */ |
Duncan Laurie | 4c14ca8 | 2018-11-20 17:27:47 -0800 | [diff] [blame] | 77 | Method (ECRW, 2, Serialized, 2) |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 78 | { |
| 79 | If (!EREG) { |
| 80 | Return (Zero) |
| 81 | } |
| 82 | |
| 83 | Local0 = DeRefOf (Arg0[0]) /* Byte offset */ |
| 84 | Local1 = DeRefOf (Arg0[1]) /* Mask */ |
| 85 | Local2 = DeRefOf (Arg0[2]) /* Read/Write */ |
| 86 | |
| 87 | OperationRegion (ERAM, EmbeddedControl, Local0, 2) |
| 88 | Field (ERAM, ByteAcc, Lock, WriteAsZeros) |
| 89 | { |
| 90 | BYT1, 8, |
| 91 | BYT2, 8, |
| 92 | } |
| 93 | |
| 94 | If (Local2 == RD) { |
| 95 | /* Read first byte */ |
| 96 | Local3 = BYT1 |
| 97 | |
| 98 | /* Read second byte if needed */ |
| 99 | FindSetLeftBit (Local1, Local4) |
| 100 | If (Local4 > 8) { |
| 101 | Local4 = BYT2 |
| 102 | Local4 <<= 8 |
| 103 | Local3 |= Local4 |
| 104 | } |
| 105 | |
| 106 | Local5 = EBIT (Arg0, Local3) |
Duncan Laurie | 4c14ca8 | 2018-11-20 17:27:47 -0800 | [diff] [blame] | 107 | If (DBUG) { |
| 108 | Printf ("ECRD %o = %o", Local0, Local5) |
| 109 | } |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 110 | Return (Local5) |
| 111 | } ElseIf (Local2 == WR) { |
| 112 | /* Write byte */ |
Duncan Laurie | 4c14ca8 | 2018-11-20 17:27:47 -0800 | [diff] [blame] | 113 | If (DBUG) { |
| 114 | Printf ("ECWR %o = %o", Local0, Arg1) |
| 115 | } |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 116 | BYT1 = Arg1 |
| 117 | } |
| 118 | Return (Zero) |
| 119 | } |
| 120 | |
| 121 | /* |
| 122 | * Read a field from EC |
| 123 | * Arg0 = EC field structure |
| 124 | */ |
Duncan Laurie | 4c14ca8 | 2018-11-20 17:27:47 -0800 | [diff] [blame] | 125 | Method (R, 1, Serialized, 2) |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 126 | { |
| 127 | Return (ECRW (Arg0, Zero)) |
| 128 | } |
| 129 | |
| 130 | /* |
| 131 | * Write value to a field from EC |
| 132 | * Arg0 = EC field structure |
| 133 | * Arg1 = Value to write |
| 134 | */ |
Duncan Laurie | 4c14ca8 | 2018-11-20 17:27:47 -0800 | [diff] [blame] | 135 | Method (W, 2, Serialized, 2) |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 136 | { |
| 137 | Return (ECRW (Arg0, Arg1)) |
| 138 | } |
| 139 | |
Duncan Laurie | 286a0ab | 2019-01-25 10:28:03 -0800 | [diff] [blame] | 140 | /* |
| 141 | * Tell EC that the OS is entering or exiting S0ix |
| 142 | */ |
| 143 | Method (S0IX, 1, Serialized) |
| 144 | { |
Duncan Laurie | 3cd3cb6 | 2020-06-09 15:13:15 -0700 | [diff] [blame] | 145 | ^ISSX = Arg0 /* Update S0ix state. */ |
| 146 | |
Duncan Laurie | 286a0ab | 2019-01-25 10:28:03 -0800 | [diff] [blame] | 147 | If (Arg0) { |
| 148 | Printf ("EC Enter S0ix") |
Felix Singer | ca4b587 | 2022-12-26 08:17:06 +0100 | [diff] [blame^] | 149 | W (CSEX, 1) |
Duncan Laurie | 6ff848a | 2019-06-13 11:07:04 -0700 | [diff] [blame] | 150 | |
| 151 | /* |
| 152 | * Read back from EC RAM after enabling S0ix |
| 153 | * to prevent EC from aborting S0ix entry. |
| 154 | */ |
| 155 | R (EVT1) |
Duncan Laurie | 286a0ab | 2019-01-25 10:28:03 -0800 | [diff] [blame] | 156 | } Else { |
| 157 | Printf ("EC Exit S0ix") |
| 158 | W (CSEX, Zero) |
Duncan Laurie | 3cd3cb6 | 2020-06-09 15:13:15 -0700 | [diff] [blame] | 159 | |
| 160 | /* If UCSI event happened during S0ix send it now. */ |
Felix Singer | ca4b587 | 2022-12-26 08:17:06 +0100 | [diff] [blame^] | 161 | If (^UCEP == 1) { |
Duncan Laurie | 3cd3cb6 | 2020-06-09 15:13:15 -0700 | [diff] [blame] | 162 | ^_Q79 () |
| 163 | } |
Duncan Laurie | 286a0ab | 2019-01-25 10:28:03 -0800 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 167 | #include "ec_dev.asl" |
| 168 | #include "ec_ram.asl" |
Duncan Laurie | 4af38d4 | 2018-10-15 15:10:21 -0700 | [diff] [blame] | 169 | #include "ac.asl" |
| 170 | #include "battery.asl" |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 171 | #include "event.asl" |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 172 | #include "lid.asl" |
| 173 | #include "platform.asl" |
Duncan Laurie | 4a2558b | 2019-02-01 11:44:14 -0800 | [diff] [blame] | 174 | #include "vbtn.asl" |
Duncan Laurie | c145e54 | 2019-04-18 16:37:50 -0700 | [diff] [blame] | 175 | #include "ucsi.asl" |
Duncan Laurie | bfb001d | 2018-12-04 10:13:25 -0800 | [diff] [blame] | 176 | #ifdef EC_ENABLE_DPTF |
Duncan Laurie | 98d7de7 | 2018-11-20 17:30:47 -0800 | [diff] [blame] | 177 | #include "dptf.asl" |
Duncan Laurie | bfb001d | 2018-12-04 10:13:25 -0800 | [diff] [blame] | 178 | #endif |
Mathew King | c650e13 | 2019-10-14 11:59:41 -0600 | [diff] [blame] | 179 | #ifdef EC_ENABLE_PRIVACY |
| 180 | #include "privacy.asl" |
| 181 | #endif |
Duncan Laurie | a802be2 | 2018-10-15 15:01:15 -0700 | [diff] [blame] | 182 | } |