| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
Scope (\_SB) |
| 4 |
{ |
| 5 |
Device (UCSI) |
| 6 |
{ |
| 7 |
Name (_HID, EisaId("USBC000")) |
| 8 |
Name (_CID, Package { "GOOG000E", EisaId ("PNP0CA0") }) |
| 9 |
Name (_DDN, "Wilco EC UCSI") |
| 10 |
Name (_UID, 1) |
| 11 |
Name (_STA, 0xf) |
| 12 |
|
| 13 |
/* Value written to EC control register to start UCSI command */ |
| 14 |
Name (UCMD, 0xE0) |
| 15 |
|
| 16 |
/* Shared memory fields are defined in the SSDT */ |
| 17 |
External (VER0, FieldUnitObj) |
| 18 |
External (VER1, FieldUnitObj) |
| 19 |
External (CCI0, FieldUnitObj) |
| 20 |
External (CCI1, FieldUnitObj) |
| 21 |
External (CCI2, FieldUnitObj) |
| 22 |
External (CCI3, FieldUnitObj) |
| 23 |
External (CTL0, FieldUnitObj) |
| 24 |
External (CTL1, FieldUnitObj) |
| 25 |
External (CTL2, FieldUnitObj) |
| 26 |
External (CTL3, FieldUnitObj) |
| 27 |
External (CTL4, FieldUnitObj) |
| 28 |
External (CTL5, FieldUnitObj) |
| 29 |
External (CTL6, FieldUnitObj) |
| 30 |
External (CTL7, FieldUnitObj) |
| 31 |
External (MGI0, FieldUnitObj) |
| 32 |
External (MGI1, FieldUnitObj) |
| 33 |
External (MGI2, FieldUnitObj) |
| 34 |
External (MGI3, FieldUnitObj) |
| 35 |
External (MGI4, FieldUnitObj) |
| 36 |
External (MGI5, FieldUnitObj) |
| 37 |
External (MGI6, FieldUnitObj) |
| 38 |
External (MGI7, FieldUnitObj) |
| 39 |
External (MGI8, FieldUnitObj) |
| 40 |
External (MGI9, FieldUnitObj) |
| 41 |
External (MGIA, FieldUnitObj) |
| 42 |
External (MGIB, FieldUnitObj) |
| 43 |
External (MGIC, FieldUnitObj) |
| 44 |
External (MGID, FieldUnitObj) |
| 45 |
External (MGIE, FieldUnitObj) |
| 46 |
External (MGIF, FieldUnitObj) |
| 47 |
External (MGO0, FieldUnitObj) |
| 48 |
External (MGO1, FieldUnitObj) |
| 49 |
External (MGO2, FieldUnitObj) |
| 50 |
External (MGO3, FieldUnitObj) |
| 51 |
External (MGO4, FieldUnitObj) |
| 52 |
External (MGO5, FieldUnitObj) |
| 53 |
External (MGO6, FieldUnitObj) |
| 54 |
External (MGO7, FieldUnitObj) |
| 55 |
External (MGO8, FieldUnitObj) |
| 56 |
External (MGO9, FieldUnitObj) |
| 57 |
External (MGOA, FieldUnitObj) |
| 58 |
External (MGOB, FieldUnitObj) |
| 59 |
External (MGOC, FieldUnitObj) |
| 60 |
External (MGOD, FieldUnitObj) |
| 61 |
External (MGOE, FieldUnitObj) |
| 62 |
External (MGOF, FieldUnitObj) |
| 63 |
|
| 64 |
Method (INIT) |
| 65 |
{ |
| 66 |
/* Read UCSI version from EC into shared memory */ |
| 67 |
^VER0 = R (^^UVR0) |
| 68 |
^VER1 = R (^^UVR1) |
| 69 |
} |
| 70 |
|
| 71 |
Method (R, 1, Serialized, 2){ |
| 72 |
Local0 = \_SB.PCI0.LPCB.EC0.R(Arg0) |
| 73 |
Return (Local0) |
| 74 |
} |
| 75 |
|
| 76 |
Method (W, 2, Serialized, 2){ |
| 77 |
\_SB.PCI0.LPCB.EC0.W(Arg0, Arg1) |
| 78 |
} |
| 79 |
|
| 80 |
Method (_DSM, 4, Serialized) |
| 81 |
{ |
| 82 |
If (Arg0 != ToUUID ("6f8398c2-7ca4-11e4-ad36-631042b5008f")) { |
| 83 |
Return (Buffer (1) { 0 }) |
| 84 |
} |
| 85 |
|
| 86 |
Switch (ToInteger (Arg2)) |
| 87 |
{ |
| 88 |
Case (0) |
| 89 |
{ |
| 90 |
Return (Buffer (1) { 0x07 }) |
| 91 |
} |
| 92 |
Case (1) |
| 93 |
{ |
| 94 |
/* Write Message Out */ |
| 95 |
W (^^UMO0, ^MGO0) |
| 96 |
W (^^UMO1, ^MGO1) |
| 97 |
W (^^UMO2, ^MGO2) |
| 98 |
W (^^UMO3, ^MGO3) |
| 99 |
W (^^UMO4, ^MGO4) |
| 100 |
W (^^UMO5, ^MGO5) |
| 101 |
W (^^UMO6, ^MGO6) |
| 102 |
W (^^UMO7, ^MGO7) |
| 103 |
W (^^UMO8, ^MGO8) |
| 104 |
W (^^UMO9, ^MGO9) |
| 105 |
W (^^UMOA, ^MGOA) |
| 106 |
W (^^UMOB, ^MGOB) |
| 107 |
W (^^UMOC, ^MGOC) |
| 108 |
W (^^UMOD, ^MGOD) |
| 109 |
W (^^UMOE, ^MGOE) |
| 110 |
W (^^UMOF, ^MGOF) |
| 111 |
|
| 112 |
/* Write Control */ |
| 113 |
W (^^UCL0, ^CTL0) |
| 114 |
W (^^UCL1, ^CTL1) |
| 115 |
W (^^UCL2, ^CTL2) |
| 116 |
W (^^UCL3, ^CTL3) |
| 117 |
W (^^UCL4, ^CTL4) |
| 118 |
W (^^UCL5, ^CTL5) |
| 119 |
W (^^UCL6, ^CTL6) |
| 120 |
W (^^UCL7, ^CTL7) |
| 121 |
|
| 122 |
/* Start EC Command */ |
| 123 |
W (^^UCTL, ^UCMD) |
| 124 |
} |
| 125 |
Case (2) |
| 126 |
{ |
| 127 |
/* Read Message In */ |
| 128 |
RMSG() |
| 129 |
} |
| 130 |
} |
| 131 |
Return (Buffer (1) { 0 }) |
| 132 |
} |
| 133 |
|
| 134 |
Method (RMSG, 0, Serialized){ |
| 135 |
/* Read Message In */ |
| 136 |
^MGI0 = R (^^UMI0) |
| 137 |
^MGI1 = R (^^UMI1) |
| 138 |
^MGI2 = R (^^UMI2) |
| 139 |
^MGI3 = R (^^UMI3) |
| 140 |
^MGI4 = R (^^UMI4) |
| 141 |
^MGI5 = R (^^UMI5) |
| 142 |
^MGI6 = R (^^UMI6) |
| 143 |
^MGI7 = R (^^UMI7) |
| 144 |
^MGI8 = R (^^UMI8) |
| 145 |
^MGI9 = R (^^UMI9) |
| 146 |
^MGIA = R (^^UMIA) |
| 147 |
^MGIB = R (^^UMIB) |
| 148 |
^MGIC = R (^^UMIC) |
| 149 |
^MGID = R (^^UMID) |
| 150 |
^MGIE = R (^^UMIE) |
| 151 |
^MGIF = R (^^UMIF) |
| 152 |
|
| 153 |
/* Read Status */ |
| 154 |
^CCI0 = R (^^UCI0) |
| 155 |
^CCI1 = R (^^UCI1) |
| 156 |
^CCI2 = R (^^UCI2) |
| 157 |
^CCI3 = R (^^UCI3) |
| 158 |
} |
| 159 |
|
| 160 |
// GPLD: Generate Port Location Data (PLD) |
| 161 |
Method (GPLD, 2, Serialized) |
| 162 |
{ |
| 163 |
Name (PCKG, Package (0x01) |
| 164 |
{ |
| 165 |
Buffer (0x10){} |
| 166 |
}) |
| 167 |
|
| 168 |
// REV: Revision 0x02 for ACPI 5.0 |
| 169 |
CreateField (DerefOf (PCKG[0]), 0, 0x07, REV) |
| 170 |
REV = 0x02 |
| 171 |
|
| 172 |
// VISI: Port visibility to user per port |
| 173 |
CreateField (DerefOf (PCKG[0]), 0x40, 1, VISI) |
| 174 |
VISI = Arg0 |
| 175 |
|
| 176 |
CreateField (DerefOf (PCKG[0]), 0x57, 0x08, GPOS) |
| 177 |
GPOS = Arg1 |
| 178 |
|
| 179 |
CreateField (DerefOf (PCKG[0]), 0x4A, 0x04, SHAP) |
| 180 |
SHAP = 0x01 |
| 181 |
|
| 182 |
CreateField (DerefOf (PCKG[0]), 0x20, 0x10, WID) |
| 183 |
WID = 0x08 |
| 184 |
|
| 185 |
CreateField (DerefOf (PCKG[0]), 0x30, 0x10, HGT) |
| 186 |
HGT = 0x03 |
| 187 |
Return (PCKG) |
| 188 |
} |
| 189 |
|
| 190 |
Method (GUPC, 1, Serialized) |
| 191 |
{ |
| 192 |
Name (PCKG, Package (0x04) |
| 193 |
{ |
| 194 |
One, |
| 195 |
Zero, |
| 196 |
Zero, |
| 197 |
Zero |
| 198 |
}) |
| 199 |
PCKG[1] = Arg0 |
| 200 |
Return (PCKG) |
| 201 |
} |
| 202 |
|
| 203 |
Device (TC01) |
| 204 |
{ |
| 205 |
Name (_ADR, 0) // _ADR: Address |
| 206 |
Method (_UPC, 0, NotSerialized) // _UPC: USB Port Capabilities |
| 207 |
{ |
| 208 |
Return (GUPC (0x09)) |
| 209 |
} |
| 210 |
|
| 211 |
Method (_PLD, 0, NotSerialized) // _PLD: Physical Location of Device |
| 212 |
{ |
| 213 |
Return (GPLD (1, 1)) |
| 214 |
} |
| 215 |
} |
| 216 |
#ifdef EC_BOARD_HAS_2ND_TYPEC_PORT |
| 217 |
Device (TC02) |
| 218 |
{ |
| 219 |
Name (_ADR, 1) // _ADR: Address |
| 220 |
Method (_UPC, 0, NotSerialized) // _UPC: USB Port Capabilities |
| 221 |
{ |
| 222 |
Return (GUPC (0x09)) |
| 223 |
} |
| 224 |
|
| 225 |
Method (_PLD, 0, NotSerialized) // _PLD: Physical Location of Device |
| 226 |
{ |
| 227 |
Return (GPLD (1, 2)) |
| 228 |
} |
| 229 |
} |
| 230 |
#endif |
| 231 |
} |
| 232 |
} |