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