| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
#include <ec/clevo/it5570e/commands.h> |
| 4 |
|
| 5 |
#define EC_DATA_IO 0x62 |
| 6 |
#define EC_SC_IO 0x66 |
| 7 |
|
| 8 |
Device (EC0) |
| 9 |
{ |
| 10 |
Name (_HID, "PNP0C09") |
| 11 |
Name (_GPE, EC_GPE_SCI) |
| 12 |
|
| 13 |
Name (_CRS, ResourceTemplate () |
| 14 |
{ |
| 15 |
IO (Decode16, 0x62, 0x62, 0, 1) |
| 16 |
IO (Decode16, 0x66, 0x66, 0, 1) |
| 17 |
}) |
| 18 |
|
| 19 |
#include <ec/acpi/ec.asl> |
| 20 |
|
| 21 |
OperationRegion (PMS0, SystemMemory, 0xfe001b1c, 4) |
| 22 |
Field (PMS0, DWordAcc, NoLock, Preserve) |
| 23 |
{ |
| 24 |
, 15, |
| 25 |
GS0E, 1, /* Global SLP_S0# enable */ |
| 26 |
} |
| 27 |
|
| 28 |
#include "ec_ram.asl" |
| 29 |
|
| 30 |
External (SFCV, MethodObj) /* Generated in SSDT */ |
| 31 |
|
| 32 |
Method (INIT) |
| 33 |
{ |
| 34 |
Printf ("EC: INIT") |
| 35 |
|
| 36 |
ECOS = 2 /* ACPI with driver */ |
| 37 |
BLCT = 1 /* Enable ACPI brightness control */ |
| 38 |
CAMK = 1 /* Enable camera hotkey */ |
| 39 |
|
| 40 |
SFCV () /* Apply custom fan curve */ |
| 41 |
|
| 42 |
PNOT () |
| 43 |
} |
| 44 |
|
| 45 |
Method (_INI) |
| 46 |
{ |
| 47 |
Printf ("EC: _INI") |
| 48 |
|
| 49 |
INIT () |
| 50 |
} |
| 51 |
|
| 52 |
/* Send FCMD */ |
| 53 |
Method (SFCC, 1, Serialized) |
| 54 |
{ |
| 55 |
FCMD = Arg0 |
| 56 |
SEND_EC_COMMAND(0) |
| 57 |
|
| 58 |
/* EC sets FCMD = 0x00 on completion (FCMD = 0xfa on some commands) */ |
| 59 |
Local0 = 50 |
| 60 |
While (Local0--) |
| 61 |
{ |
| 62 |
Stall (1) |
| 63 |
If (FCMD == 0x00 || FCMD == 0xfa) |
| 64 |
{ |
| 65 |
Printf("EC: FCMD 0x%o completed after %o ms", |
| 66 |
ToHexString(Arg0), ToDecimalString(50 - Local0)) |
| 67 |
Return (1) |
| 68 |
} |
| 69 |
} |
| 70 |
Printf("EC: FCMD 0x%o timed out", ToHexString(Arg0)) |
| 71 |
Return (0) |
| 72 |
} |
| 73 |
|
| 74 |
/* |
| 75 |
* Method called from _PTS prior to system sleep state entry |
| 76 |
*/ |
| 77 |
Method (PTS, 1, Serialized) |
| 78 |
{ |
| 79 |
Printf ("EC: PTS: Arg0=%o", ToDecimalString(Arg0)) |
| 80 |
|
| 81 |
WFNO = 0 /* Clear wake cause */ |
| 82 |
} |
| 83 |
|
| 84 |
/* |
| 85 |
* Method called from _WAK prior to system sleep state wakeup |
| 86 |
*/ |
| 87 |
Method (WAK, 1, Serialized) |
| 88 |
{ |
| 89 |
Printf ("EC: WAK: Arg0=%o, WFNO=%o", ToDecimalString(Arg0), ToHexString (WFNO)) |
| 90 |
|
| 91 |
INIT () |
| 92 |
|
| 93 |
/* update battery */ |
| 94 |
Notify (\_SB.BAT0, 0x00) /* bus check */ |
| 95 |
Notify (\_SB.BAT0, 0x80) /* state change */ |
| 96 |
Notify (\_SB.BAT0, 0x81) /* information change */ |
| 97 |
|
| 98 |
/* update AC */ |
| 99 |
Notify (\_SB.AC, 0x00) /* bus check */ |
| 100 |
Notify (\_SB.AC, 0x80) /* state change */ |
| 101 |
|
| 102 |
If (Arg0 == 0x03 || Arg0 == 0x04) { |
| 103 |
Notify (\_SB.PWRB, 0x02) /* Wake */ |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
/* |
| 108 |
* Display On/Off Notifications |
| 109 |
* Called from \_SB.PEPD._DSM |
| 110 |
*/ |
| 111 |
Name (KBLV, 0) |
| 112 |
Method (EDSX, 1, Serialized) |
| 113 |
{ |
| 114 |
Printf ("EC: PEP display hook, state=%o", ToDecimalString (Arg0)) |
| 115 |
|
| 116 |
If (S5FG) |
| 117 |
{ |
| 118 |
Return () |
| 119 |
} |
| 120 |
|
| 121 |
/* Display off */ |
| 122 |
If (!Arg0) |
| 123 |
{ |
| 124 |
/* Store current keyboard backlight level */ |
| 125 |
FDAT = FDAT_KBLED_WHITE_GET_LEVEL |
| 126 |
SFCC (FCMD_KLED) |
| 127 |
KBLV = FBUF |
| 128 |
|
| 129 |
/* Turn off keyboard backlight */ |
| 130 |
FDAT = FDAT_KBLED_WHITE_SET_LEVEL |
| 131 |
FBUF = 0x00 |
| 132 |
SFCC (FCMD_KLED) |
| 133 |
} |
| 134 |
|
| 135 |
/* Display on */ |
| 136 |
Else |
| 137 |
{ |
| 138 |
/* Restore keyboard backlight level */ |
| 139 |
FDAT = FDAT_KBLED_WHITE_SET_LEVEL |
| 140 |
FBUF = KBLV |
| 141 |
SFCC (FCMD_KLED) |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
/* |
| 146 |
* S0ix Entry/Exit Notifications |
| 147 |
* Called from \_SB.PEPD._DSM |
| 148 |
*/ |
| 149 |
Method (S0IX, 1, Serialized) |
| 150 |
{ |
| 151 |
If (S5FG) |
| 152 |
{ |
| 153 |
Return () |
| 154 |
} |
| 155 |
|
| 156 |
Printf ("EC: S0ix change, state=%o", ToDecimalString (Arg0)) |
| 157 |
|
| 158 |
/* S0ix entry */ |
| 159 |
If (Arg0) |
| 160 |
{ |
| 161 |
MSFG = 1 /* Notify EC */ |
| 162 |
} |
| 163 |
|
| 164 |
/* S0ix exit */ |
| 165 |
Else |
| 166 |
{ |
| 167 |
GS0E = 0 /* Block SLP_S0# assertion during wakeup */ |
| 168 |
MSFG = 0 /* Notfiy EC */ |
| 169 |
Sleep (150) /* wait for EC to become ready */ |
| 170 |
SFCV () /* Apply custom fan curve */ |
| 171 |
GS0E = 1 /* Unblock SLP_S0# */ |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
#include "ec_queries.asl" |
| 176 |
} |