Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 2 | |
Furquan Shaikh | 56eafbb | 2020-04-30 18:38:55 -0700 | [diff] [blame] | 3 | #ifndef __ACPI_ACPIGEN_H__ |
| 4 | #define __ACPI_ACPIGEN_H__ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 5 | |
Elyes HAOUAS | 5817c56 | 2020-07-12 09:03:22 +0200 | [diff] [blame] | 6 | #include <stddef.h> |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 7 | #include <stdint.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 8 | #include <acpi/acpi.h> |
| 9 | #include <acpi/acpi_device.h> |
| 10 | #include <acpi/acpi_pld.h> |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 11 | #include <device/pci_type.h> |
| 12 | |
| 13 | /* Values that can be returned for ACPI Device _STA method */ |
| 14 | #define ACPI_STATUS_DEVICE_PRESENT (1 << 0) |
| 15 | #define ACPI_STATUS_DEVICE_ENABLED (1 << 1) |
| 16 | #define ACPI_STATUS_DEVICE_SHOW_IN_UI (1 << 2) |
| 17 | #define ACPI_STATUS_DEVICE_STATE_OK (1 << 3) |
| 18 | |
| 19 | #define ACPI_STATUS_DEVICE_ALL_OFF 0 |
| 20 | #define ACPI_STATUS_DEVICE_ALL_ON (ACPI_STATUS_DEVICE_PRESENT |\ |
| 21 | ACPI_STATUS_DEVICE_ENABLED |\ |
| 22 | ACPI_STATUS_DEVICE_SHOW_IN_UI |\ |
| 23 | ACPI_STATUS_DEVICE_STATE_OK) |
| 24 | #define ACPI_STATUS_DEVICE_HIDDEN_ON (ACPI_STATUS_DEVICE_PRESENT |\ |
| 25 | ACPI_STATUS_DEVICE_ENABLED |\ |
| 26 | ACPI_STATUS_DEVICE_STATE_OK) |
| 27 | |
| 28 | /* ACPI Op/Prefix Codes */ |
| 29 | enum { |
| 30 | ZERO_OP = 0x00, |
| 31 | ONE_OP = 0x01, |
| 32 | ALIAS_OP = 0x06, |
| 33 | NAME_OP = 0x08, |
| 34 | BYTE_PREFIX = 0x0A, |
| 35 | WORD_PREFIX = 0x0B, |
| 36 | DWORD_PREFIX = 0x0C, |
| 37 | STRING_PREFIX = 0x0D, |
| 38 | QWORD_PREFIX = 0x0E, |
| 39 | SCOPE_OP = 0x10, |
| 40 | BUFFER_OP = 0x11, |
| 41 | PACKAGE_OP = 0x12, |
| 42 | VARIABLE_PACKAGE_OP = 0x13, |
| 43 | METHOD_OP = 0x14, |
| 44 | EXTERNAL_OP = 0x15, |
| 45 | DUAL_NAME_PREFIX = 0x2E, |
| 46 | MULTI_NAME_PREFIX = 0x2F, |
| 47 | EXT_OP_PREFIX = 0x5B, |
| 48 | MUTEX_OP = 0x01, |
Elyes Haouas | b2d5e46 | 2023-02-07 13:03:09 +0100 | [diff] [blame] | 49 | EVENT_OP = 0x02, |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 50 | SF_RIGHT_OP = 0x10, |
| 51 | SF_LEFT_OP = 0x11, |
| 52 | COND_REFOF_OP = 0x12, |
| 53 | CREATEFIELD_OP = 0x13, |
| 54 | LOAD_TABLE_OP = 0x1f, |
| 55 | LOAD_OP = 0x20, |
| 56 | STALL_OP = 0x21, |
| 57 | SLEEP_OP = 0x22, |
| 58 | ACQUIRE_OP = 0x23, |
| 59 | SIGNAL_OP = 0x24, |
| 60 | WAIT_OP = 0x25, |
| 61 | RST_OP = 0x26, |
| 62 | RELEASE_OP = 0x27, |
| 63 | FROM_BCD_OP = 0x28, |
| 64 | TO_BCD_OP = 0x29, |
| 65 | UNLOAD_OP = 0x2A, |
| 66 | REVISON_OP = 0x30, |
| 67 | DEBUG_OP = 0x31, |
| 68 | FATAL_OP = 0x32, |
| 69 | TIMER_OP = 0x33, |
| 70 | OPREGION_OP = 0x80, |
| 71 | FIELD_OP = 0x81, |
| 72 | DEVICE_OP = 0x82, |
| 73 | PROCESSOR_OP = 0x83, |
| 74 | POWER_RES_OP = 0x84, |
| 75 | THERMAL_ZONE_OP = 0x85, |
| 76 | INDEX_FIELD_OP = 0x86, |
| 77 | BANK_FIELD_OP = 0x87, |
| 78 | DATA_REGION_OP = 0x88, |
| 79 | ROOT_PREFIX = 0x5C, |
| 80 | PARENT_PREFIX = 0x5E, |
| 81 | LOCAL0_OP = 0x60, |
| 82 | LOCAL1_OP = 0x61, |
| 83 | LOCAL2_OP = 0x62, |
| 84 | LOCAL3_OP = 0x63, |
| 85 | LOCAL4_OP = 0x64, |
| 86 | LOCAL5_OP = 0x65, |
| 87 | LOCAL6_OP = 0x66, |
| 88 | LOCAL7_OP = 0x67, |
| 89 | ARG0_OP = 0x68, |
| 90 | ARG1_OP = 0x69, |
| 91 | ARG2_OP = 0x6A, |
| 92 | ARG3_OP = 0x6B, |
| 93 | ARG4_OP = 0x6C, |
| 94 | ARG5_OP = 0x6D, |
| 95 | ARG6_OP = 0x6E, |
| 96 | STORE_OP = 0x70, |
| 97 | REF_OF_OP = 0x71, |
| 98 | ADD_OP = 0x72, |
| 99 | CONCATENATE_OP = 0x73, |
| 100 | SUBTRACT_OP = 0x74, |
| 101 | INCREMENT_OP = 0x75, |
| 102 | DECREMENT_OP = 0x76, |
| 103 | MULTIPLY_OP = 0x77, |
| 104 | DIVIDE_OP = 0x78, |
| 105 | SHIFT_LEFT_OP = 0x79, |
| 106 | SHIFT_RIGHT_OP = 0x7A, |
| 107 | AND_OP = 0x7B, |
| 108 | NAND_OP = 0x7C, |
| 109 | OR_OP = 0x7D, |
| 110 | NOR_OP = 0x7E, |
| 111 | XOR_OP = 0x7F, |
| 112 | NOT_OP = 0x80, |
| 113 | FD_SHIFT_LEFT_BIT_OR = 0x81, |
| 114 | FD_SHIFT_RIGHT_BIT_OR = 0x82, |
| 115 | DEREF_OP = 0x83, |
| 116 | CONCATENATE_TEMP_OP = 0x84, |
| 117 | MOD_OP = 0x85, |
| 118 | NOTIFY_OP = 0x86, |
| 119 | SIZEOF_OP = 0x87, |
| 120 | INDEX_OP = 0x88, |
| 121 | MATCH_OP = 0x89, |
| 122 | CREATE_DWORD_OP = 0x8A, |
| 123 | CREATE_WORD_OP = 0x8B, |
| 124 | CREATE_BYTE_OP = 0x8C, |
| 125 | CREATE_BIT_OP = 0x8D, |
| 126 | OBJ_TYPE_OP = 0x8E, |
| 127 | CREATE_QWORD_OP = 0x8F, |
| 128 | LAND_OP = 0x90, |
| 129 | LOR_OP = 0x91, |
| 130 | LNOT_OP = 0x92, |
| 131 | LEQUAL_OP = 0x93, |
| 132 | LGREATER_OP = 0x94, |
| 133 | LLESS_OP = 0x95, |
| 134 | TO_BUFFER_OP = 0x96, |
| 135 | TO_DEC_STRING_OP = 0x97, |
| 136 | TO_HEX_STRING_OP = 0x98, |
| 137 | TO_INTEGER_OP = 0x99, |
| 138 | TO_STRING_OP = 0x9C, |
| 139 | CP_OBJ_OP = 0x9D, |
| 140 | MID_OP = 0x9E, |
| 141 | CONTINUE_OP = 0x9F, |
| 142 | IF_OP = 0xA0, |
| 143 | ELSE_OP = 0xA1, |
| 144 | WHILE_OP = 0xA2, |
| 145 | NOOP_OP = 0xA3, |
| 146 | RETURN_OP = 0xA4, |
| 147 | BREAK_OP = 0xA5, |
| 148 | COMMENT_OP = 0xA9, |
| 149 | BREAKPIONT_OP = 0xCC, |
| 150 | ONES_OP = 0xFF, |
| 151 | }; |
| 152 | |
| 153 | #define FIELDLIST_OFFSET(X) { .type = OFFSET, \ |
| 154 | .name = "",\ |
| 155 | .bits = X * 8, \ |
| 156 | } |
| 157 | #define FIELDLIST_NAMESTR(X, Y) { .type = NAME_STRING, \ |
| 158 | .name = X, \ |
| 159 | .bits = Y, \ |
| 160 | } |
Duncan Laurie | 095bbf9 | 2020-09-30 23:09:29 +0000 | [diff] [blame] | 161 | #define FIELDLIST_RESERVED(X) { .type = RESERVED, \ |
| 162 | .name = "", \ |
| 163 | .bits = X, \ |
| 164 | } |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 165 | |
| 166 | #define FIELD_ANYACC 0 |
| 167 | #define FIELD_BYTEACC 1 |
| 168 | #define FIELD_WORDACC 2 |
| 169 | #define FIELD_DWORDACC 3 |
| 170 | #define FIELD_QWORDACC 4 |
| 171 | #define FIELD_BUFFERACC 5 |
| 172 | #define FIELD_NOLOCK (0<<4) |
| 173 | #define FIELD_LOCK (1<<4) |
| 174 | #define FIELD_PRESERVE (0<<5) |
| 175 | #define FIELD_WRITEASONES (1<<5) |
| 176 | #define FIELD_WRITEASZEROS (2<<5) |
| 177 | |
| 178 | enum field_type { |
| 179 | OFFSET, |
| 180 | NAME_STRING, |
Duncan Laurie | 095bbf9 | 2020-09-30 23:09:29 +0000 | [diff] [blame] | 181 | RESERVED, |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 182 | FIELD_TYPE_MAX, |
| 183 | }; |
| 184 | |
| 185 | struct fieldlist { |
| 186 | enum field_type type; |
| 187 | const char *name; |
| 188 | u32 bits; |
| 189 | }; |
| 190 | |
| 191 | #define OPREGION(rname, space, offset, len) {.name = rname, \ |
| 192 | .regionspace = space, \ |
| 193 | .regionoffset = offset, \ |
| 194 | .regionlen = len, \ |
| 195 | } |
| 196 | |
| 197 | enum region_space { |
| 198 | SYSTEMMEMORY, |
| 199 | SYSTEMIO, |
| 200 | PCI_CONFIG, |
| 201 | EMBEDDEDCONTROL, |
| 202 | SMBUS, |
| 203 | CMOS, |
| 204 | PCIBARTARGET, |
| 205 | IPMI, |
| 206 | GPIO_REGION, |
| 207 | GPSERIALBUS, |
| 208 | PCC, |
| 209 | FIXED_HARDWARE = 0x7F, |
| 210 | REGION_SPACE_MAX, |
| 211 | }; |
| 212 | |
Eran Mitrani | f39e296 | 2022-07-11 10:46:46 -0700 | [diff] [blame] | 213 | enum acpi_resource_type { |
| 214 | RSRC_TYPE_MEM = 0, |
| 215 | RSRC_TYPE_IO = 1, |
| 216 | RSRC_TYPE_BUS = 2 |
| 217 | }; |
| 218 | |
| 219 | enum acpi_decode_type { |
| 220 | DECODE_10, |
| 221 | DECODE_16 |
| 222 | }; |
| 223 | |
| 224 | enum acpi_read_write_type { |
| 225 | READ_ONLY, |
| 226 | READ_WRITE |
| 227 | }; |
| 228 | |
| 229 | enum acpi_cacheable_type { |
| 230 | NON_CACHEABLE, |
| 231 | CACHEABLE |
| 232 | }; |
| 233 | |
| 234 | enum acpi_resource_subtype { |
| 235 | DWORD_IO, |
| 236 | DWORD_MEMORY, |
| 237 | IO, |
| 238 | MEMORY_32_FIXED, |
| 239 | QWORD_MEMORY, |
| 240 | WORD_BUS_NUMBER |
| 241 | }; |
| 242 | |
| 243 | /* macros for ACPI Table 6.49 Memory Resource Flag (Resource Type = 0) */ |
| 244 | #define MEM_RSRC_FLAG_TRNSL_TYPE_STATIC 0x0 |
| 245 | #define MEM_RSRC_FLAG_TRNSL_TYPE_TRANSLATION (0x1 << 5) |
| 246 | #define MEM_RSRC_FLAG_ADDR_RNG_MEM 0x0 |
| 247 | #define MEM_RSRC_FLAG_ADDR_RNG_RSV (0x1 << 3) |
| 248 | #define MEM_RSRC_FLAG_ADDR_RNG_ACPI (0x2 << 3) |
| 249 | #define MEM_RSRC_FLAG_ADDR_RNG_NVA (0x3 << 3) |
| 250 | #define MEM_RSRC_FLAG_MEM_ATTR_NON_CACHE 0x0 |
| 251 | #define MEM_RSRC_FLAG_MEM_ATTR_CACHE (0x1 << 1) |
| 252 | #define MEM_RSRC_FLAG_MEM_ATTR_CACHE_WRT (0x2 << 1) |
| 253 | #define MEM_RSRC_FLAG_MEM_ATTR_CACHE_PREFETCH (0x3 << 1) |
| 254 | #define MEM_RSRC_FLAG_MEM_READ_ONLY 0x0 |
| 255 | #define MEM_RSRC_FLAG_MEM_READ_WRITE 0x1 |
| 256 | |
| 257 | /* macros for ACPI Table 6.50 I/O Resource Flag (Resource Type = 1) */ |
| 258 | #define IO_RSRC_FLAG_ENTIRE_RANGE 0x3 |
| 259 | #define IO_RSRC_FLAG_ISA_ONLY 0x2 |
| 260 | #define IO_RSRC_FLAG_NON_ISA_ONLY 0x1 |
| 261 | #define IO_RSRC_FLAG_TRASL_TYPE_STATIC 0x0 |
| 262 | #define IO_RSRC_FLAG_TRNSL_TYPE_TRANSLATION (0x1 << 4) |
| 263 | #define IO_RSRC_FLAG_SPRS_TRASL_DENSE 0x0 |
| 264 | #define IO_RSRC_FLAG_SPRS_TRNSL_SPARSE (0x1 << 5) |
| 265 | |
| 266 | /* macro for ACPI Table 6.51 Bus Number Range Resource Flag (Resource Type = 2) */ |
| 267 | #define BUS_NUM_RANGE_RESOURCE_FLAG 0x0 // reserved |
| 268 | |
| 269 | /* General Flags for WORD Address Space Descriptor Definition (ACPI Table 6.47, byte 4)*/ |
| 270 | #define ADDR_SPACE_GENERAL_FLAG_MAX_FIXED (0x1 << 3) |
| 271 | #define ADDR_SPACE_GENERAL_FLAG_MAX_NOT_FIXED 0x0 |
| 272 | #define ADDR_SPACE_GENERAL_FLAG_MIN_FIXED (0x1 << 2) |
| 273 | #define ADDR_SPACE_GENERAL_FLAG_MIN_NOT_FIXED 0x0 |
| 274 | #define ADDR_SPACE_GENERAL_FLAG_DEC_SUB (0x1 << 1) |
| 275 | #define ADDR_SPACE_GENERAL_FLAG_DEC_POS 0x0 |
| 276 | #define ADDR_SPACE_GENERAL_FLAG_CONSUMER 0x10 |
| 277 | #define ADDR_SPACE_GENERAL_FLAG_PRODUCER 0x0 |
| 278 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 279 | struct opregion { |
| 280 | const char *name; |
| 281 | enum region_space regionspace; |
| 282 | unsigned long regionoffset; |
| 283 | unsigned long regionlen; |
| 284 | }; |
| 285 | |
| 286 | #define DSM_UUID(DSM_UUID, DSM_CALLBACKS, DSM_COUNT, DSM_ARG) \ |
| 287 | { .uuid = DSM_UUID, \ |
| 288 | .callbacks = DSM_CALLBACKS, \ |
| 289 | .count = DSM_COUNT, \ |
| 290 | .arg = DSM_ARG, \ |
| 291 | } |
| 292 | |
| 293 | struct dsm_uuid { |
| 294 | const char *uuid; |
| 295 | void (**callbacks)(void *); |
| 296 | size_t count; |
| 297 | void *arg; |
| 298 | }; |
| 299 | |
Michael Niewöhner | d5fc04b | 2020-10-29 22:38:32 +0100 | [diff] [blame] | 300 | #define CPPC_VERSION_1 1 |
| 301 | #define CPPC_VERSION_2 2 |
| 302 | #define CPPC_VERSION_3 3 |
| 303 | |
Sridhar Siricilla | 0fd7340 | 2021-11-15 17:12:49 +0530 | [diff] [blame] | 304 | #define CPPC_PACKAGE_NAME "GCPC" |
| 305 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 306 | /*version 1 has 15 fields, version 2 has 19, and version 3 has 21 */ |
| 307 | enum cppc_fields { |
| 308 | CPPC_HIGHEST_PERF, /* can be DWORD */ |
| 309 | CPPC_NOMINAL_PERF, /* can be DWORD */ |
| 310 | CPPC_LOWEST_NONL_PERF, /* can be DWORD */ |
| 311 | CPPC_LOWEST_PERF, /* can be DWORD */ |
| 312 | CPPC_GUARANTEED_PERF, |
| 313 | CPPC_DESIRED_PERF, |
| 314 | CPPC_MIN_PERF, |
| 315 | CPPC_MAX_PERF, |
| 316 | CPPC_PERF_REDUCE_TOLERANCE, |
| 317 | CPPC_TIME_WINDOW, |
| 318 | CPPC_COUNTER_WRAP, /* can be DWORD */ |
| 319 | CPPC_REF_PERF_COUNTER, |
| 320 | CPPC_DELIVERED_PERF_COUNTER, |
| 321 | CPPC_PERF_LIMITED, |
| 322 | CPPC_ENABLE, /* can be System I/O */ |
| 323 | CPPC_MAX_FIELDS_VER_1, |
| 324 | CPPC_AUTO_SELECT = /* can be DWORD */ |
| 325 | CPPC_MAX_FIELDS_VER_1, |
| 326 | CPPC_AUTO_ACTIVITY_WINDOW, |
| 327 | CPPC_PERF_PREF, |
| 328 | CPPC_REF_PERF, /* can be DWORD */ |
| 329 | CPPC_MAX_FIELDS_VER_2, |
| 330 | CPPC_LOWEST_FREQ = /* can be DWORD */ |
| 331 | CPPC_MAX_FIELDS_VER_2, |
| 332 | CPPC_NOMINAL_FREQ, /* can be DWORD */ |
| 333 | CPPC_MAX_FIELDS_VER_3, |
| 334 | }; |
| 335 | |
Michael Niewöhner | 38107fa | 2021-10-05 22:22:21 +0200 | [diff] [blame] | 336 | typedef struct cppc_entry { |
| 337 | enum { CPPC_TYPE_REG, CPPC_TYPE_DWORD } type; |
| 338 | union { |
| 339 | acpi_addr_t reg; |
| 340 | uint32_t dword; |
| 341 | }; |
| 342 | } cppc_entry_t; |
| 343 | |
| 344 | #define CPPC_DWORD(_dword) \ |
| 345 | (cppc_entry_t){ \ |
| 346 | .type = CPPC_TYPE_DWORD, \ |
| 347 | .dword = _dword, \ |
| 348 | } |
| 349 | |
| 350 | #define CPPC_REG(_reg) \ |
| 351 | (cppc_entry_t){ \ |
| 352 | .type = CPPC_TYPE_REG, \ |
| 353 | .reg = _reg, \ |
| 354 | } |
| 355 | |
| 356 | #define CPPC_REG_MSR(address, offset, width) CPPC_REG(ACPI_REG_MSR(address, offset, width)) |
| 357 | #define CPPC_UNSUPPORTED CPPC_REG(ACPI_REG_UNSUPPORTED) |
| 358 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 359 | struct cppc_config { |
| 360 | u32 version; /* must be 1, 2, or 3 */ |
| 361 | /* |
| 362 | * The generic acpi_addr_t structure is being used, though |
| 363 | * anything besides PPC or FFIXED generally requires checking |
| 364 | * if the OS has advertised support for it (via _OSC). |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 365 | */ |
Michael Niewöhner | 38107fa | 2021-10-05 22:22:21 +0200 | [diff] [blame] | 366 | cppc_entry_t entries[CPPC_MAX_FIELDS_VER_3]; |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 367 | }; |
| 368 | |
Tim Wawrzynczak | 1883106 | 2021-12-02 15:56:42 -0700 | [diff] [blame] | 369 | #define ACPI_MUTEX_NO_TIMEOUT 0xffff |
| 370 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 371 | void acpigen_write_return_integer(uint64_t arg); |
Duncan Laurie | ec2e3e4 | 2020-11-03 15:19:08 -0800 | [diff] [blame] | 372 | void acpigen_write_return_namestr(const char *arg); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 373 | void acpigen_write_return_string(const char *arg); |
| 374 | void acpigen_write_len_f(void); |
| 375 | void acpigen_pop_len(void); |
| 376 | void acpigen_set_current(char *curr); |
| 377 | char *acpigen_get_current(void); |
| 378 | char *acpigen_write_package(int nr_el); |
Jakub Czapiga | 1799290 | 2022-10-27 14:12:55 +0200 | [diff] [blame] | 379 | __always_inline void acpigen_write_package_end(void) |
Jakub Czapiga | 61fcb7e | 2021-02-19 11:44:22 +0100 | [diff] [blame] | 380 | { |
| 381 | acpigen_pop_len(); |
| 382 | } |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 383 | void acpigen_write_zero(void); |
| 384 | void acpigen_write_one(void); |
| 385 | void acpigen_write_ones(void); |
| 386 | void acpigen_write_byte(unsigned int data); |
| 387 | void acpigen_emit_byte(unsigned char data); |
| 388 | void acpigen_emit_ext_op(uint8_t op); |
| 389 | void acpigen_emit_word(unsigned int data); |
| 390 | void acpigen_emit_dword(unsigned int data); |
| 391 | void acpigen_emit_stream(const char *data, int size); |
| 392 | void acpigen_emit_string(const char *string); |
| 393 | void acpigen_emit_namestring(const char *namepath); |
| 394 | void acpigen_emit_eisaid(const char *eisaid); |
| 395 | void acpigen_write_word(unsigned int data); |
| 396 | void acpigen_write_dword(unsigned int data); |
| 397 | void acpigen_write_qword(uint64_t data); |
| 398 | void acpigen_write_integer(uint64_t data); |
| 399 | void acpigen_write_string(const char *string); |
| 400 | void acpigen_write_name_unicode(const char *name, const char *string); |
| 401 | void acpigen_write_name(const char *name); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 402 | void acpigen_write_name_string(const char *name, const char *string); |
| 403 | void acpigen_write_name_dword(const char *name, uint32_t val); |
| 404 | void acpigen_write_name_qword(const char *name, uint64_t val); |
| 405 | void acpigen_write_name_byte(const char *name, uint8_t val); |
| 406 | void acpigen_write_name_integer(const char *name, uint64_t val); |
| 407 | void acpigen_write_coreboot_hid(enum coreboot_acpi_ids id); |
| 408 | void acpigen_write_scope(const char *name); |
Jakub Czapiga | 1799290 | 2022-10-27 14:12:55 +0200 | [diff] [blame] | 409 | __always_inline void acpigen_write_scope_end(void) |
Jakub Czapiga | 61fcb7e | 2021-02-19 11:44:22 +0100 | [diff] [blame] | 410 | { |
| 411 | acpigen_pop_len(); |
| 412 | } |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 413 | void acpigen_write_method(const char *name, int nargs); |
| 414 | void acpigen_write_method_serialized(const char *name, int nargs); |
Jakub Czapiga | 1799290 | 2022-10-27 14:12:55 +0200 | [diff] [blame] | 415 | __always_inline void acpigen_write_method_end(void) |
Jakub Czapiga | 61fcb7e | 2021-02-19 11:44:22 +0100 | [diff] [blame] | 416 | { |
| 417 | acpigen_pop_len(); |
| 418 | } |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 419 | void acpigen_write_device(const char *name); |
Jakub Czapiga | 1799290 | 2022-10-27 14:12:55 +0200 | [diff] [blame] | 420 | __always_inline void acpigen_write_device_end(void) |
Jakub Czapiga | 61fcb7e | 2021-02-19 11:44:22 +0100 | [diff] [blame] | 421 | { |
| 422 | acpigen_pop_len(); |
| 423 | } |
Raul E Rangel | 052c963 | 2021-05-12 17:01:30 -0600 | [diff] [blame] | 424 | void acpigen_write_thermal_zone(const char *name); |
Jakub Czapiga | 1799290 | 2022-10-27 14:12:55 +0200 | [diff] [blame] | 425 | __always_inline void acpigen_write_thermal_zone_end(void) |
Raul E Rangel | 052c963 | 2021-05-12 17:01:30 -0600 | [diff] [blame] | 426 | { |
| 427 | acpigen_pop_len(); |
| 428 | } |
Raul E Rangel | c704832 | 2021-04-19 15:58:25 -0600 | [diff] [blame] | 429 | void acpigen_write_LPI_package(u64 level, const struct acpi_lpi_state *states, u16 nentries); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 430 | void acpigen_write_PPC(u8 nr); |
| 431 | void acpigen_write_PPC_NVS(void); |
| 432 | void acpigen_write_empty_PCT(void); |
| 433 | void acpigen_write_empty_PTC(void); |
Kyösti Mälkki | ddc37d6 | 2023-04-17 12:11:03 +0300 | [diff] [blame] | 434 | void acpigen_write_PTC(uint8_t duty_width, uint8_t duty_offset, uint16_t p_cnt); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 435 | void acpigen_write_PRW(u32 wake, u32 level); |
| 436 | void acpigen_write_STA(uint8_t status); |
Sugnan Prabhu S | 4f77f61 | 2020-06-10 09:51:02 +0530 | [diff] [blame] | 437 | void acpigen_write_STA_ext(const char *namestring); |
Felix Held | 2d4112f | 2023-05-04 23:00:06 +0200 | [diff] [blame] | 438 | void acpigen_write_BBN(uint8_t base_bus_number); |
Felix Held | 75c4d44 | 2024-01-11 23:57:38 +0100 | [diff] [blame] | 439 | void acpigen_write_SEG(uint8_t segment_group_number); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 440 | void acpigen_write_TPC(const char *gnvs_tpc_limit); |
| 441 | void acpigen_write_PSS_package(u32 coreFreq, u32 power, u32 transLat, |
| 442 | u32 busmLat, u32 control, u32 status); |
Jason Glenesk | ca36aed | 2020-09-15 21:01:57 -0700 | [diff] [blame] | 443 | void acpigen_write_pss_object(const struct acpi_sw_pstate *pstate_values, size_t nentries); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 444 | typedef enum { SW_ALL = 0xfc, SW_ANY = 0xfd, HW_ALL = 0xfe } PSD_coord; |
| 445 | void acpigen_write_PSD_package(u32 domain, u32 numprocs, PSD_coord coordtype); |
Angel Pons | d2794ce | 2021-10-17 12:59:43 +0200 | [diff] [blame] | 446 | void acpigen_write_CST_package_entry(const acpi_cstate_t *cstate); |
| 447 | void acpigen_write_CST_package(const acpi_cstate_t *entry, int nentries); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 448 | typedef enum { CSD_HW_ALL = 0xfe } CSD_coord; |
| 449 | void acpigen_write_CSD_package(u32 domain, u32 numprocs, CSD_coord coordtype, |
| 450 | u32 index); |
Jason Glenesk | ca36aed | 2020-09-15 21:01:57 -0700 | [diff] [blame] | 451 | void acpigen_write_pct_package(const acpi_addr_t *perf_ctrl, const acpi_addr_t *perf_sts); |
| 452 | void acpigen_write_xpss_package(const struct acpi_xpss_sw_pstate *pstate_value); |
| 453 | void acpigen_write_xpss_object(const struct acpi_xpss_sw_pstate *pstate_values, |
| 454 | size_t nentries); |
Felix Held | b57b12f | 2023-01-24 19:31:00 +0100 | [diff] [blame] | 455 | void acpigen_write_processor_namestring(unsigned int cpu_index); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 456 | void acpigen_write_processor(u8 cpuindex, u32 pblock_addr, u8 pblock_len); |
Jakub Czapiga | 1799290 | 2022-10-27 14:12:55 +0200 | [diff] [blame] | 457 | __always_inline void acpigen_write_processor_end(void) |
Jakub Czapiga | 61fcb7e | 2021-02-19 11:44:22 +0100 | [diff] [blame] | 458 | { |
| 459 | acpigen_pop_len(); |
| 460 | } |
Felix Held | 32bba18 | 2023-01-28 03:37:21 +0100 | [diff] [blame] | 461 | void acpigen_write_processor_device(unsigned int cpu_index); |
| 462 | __always_inline void acpigen_write_processor_device_end(void) |
| 463 | { |
| 464 | acpigen_pop_len(); |
| 465 | } |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 466 | void acpigen_write_processor_package(const char *name, |
| 467 | unsigned int first_core, |
| 468 | unsigned int core_count); |
| 469 | void acpigen_write_processor_cnot(const unsigned int number_of_cores); |
| 470 | void acpigen_write_TSS_package(int entries, acpi_tstate_t *tstate_list); |
| 471 | void acpigen_write_TSD_package(u32 domain, u32 numprocs, PSD_coord coordtype); |
| 472 | void acpigen_write_mem32fixed(int readwrite, u32 base, u32 size); |
| 473 | void acpigen_write_io16(u16 min, u16 max, u8 align, u8 len, u8 decode16); |
| 474 | void acpigen_write_register_resource(const acpi_addr_t *addr); |
| 475 | void acpigen_write_resourcetemplate_header(void); |
| 476 | void acpigen_write_resourcetemplate_footer(void); |
| 477 | void acpigen_write_mainboard_resource_template(void); |
| 478 | void acpigen_write_mainboard_resources(const char *scope, const char *name); |
| 479 | void acpigen_write_irq(u16 mask); |
| 480 | void acpigen_write_uuid(const char *uuid); |
| 481 | void acpigen_write_power_res(const char *name, uint8_t level, uint16_t order, |
| 482 | const char * const dev_states[], size_t dev_states_count); |
Jakub Czapiga | 1799290 | 2022-10-27 14:12:55 +0200 | [diff] [blame] | 483 | __always_inline void acpigen_write_power_res_end(void) |
Jakub Czapiga | 61fcb7e | 2021-02-19 11:44:22 +0100 | [diff] [blame] | 484 | { |
| 485 | acpigen_pop_len(); |
| 486 | } |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 487 | void acpigen_write_sleep(uint64_t sleep_ms); |
| 488 | void acpigen_write_store(void); |
Duncan Laurie | 8e391d3 | 2020-09-30 23:17:41 +0000 | [diff] [blame] | 489 | void acpigen_write_store_int_to_namestr(uint64_t src, const char *dst); |
| 490 | void acpigen_write_store_int_to_op(uint64_t src, uint8_t dst); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 491 | void acpigen_write_store_ops(uint8_t src, uint8_t dst); |
| 492 | void acpigen_write_store_op_to_namestr(uint8_t src, const char *dst); |
Cliff Huang | 24f3dc8 | 2023-02-04 21:11:51 -0800 | [diff] [blame] | 493 | void acpigen_write_store_namestr_to_op(const char *src, uint8_t dst); |
Felix Held | 178cf35 | 2023-02-09 16:29:46 +0100 | [diff] [blame] | 494 | void acpigen_write_store_namestr_to_namestr(const char *src, const char *dst); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 495 | void acpigen_write_or(uint8_t arg1, uint8_t arg2, uint8_t res); |
| 496 | void acpigen_write_xor(uint8_t arg1, uint8_t arg2, uint8_t res); |
| 497 | void acpigen_write_and(uint8_t arg1, uint8_t arg2, uint8_t res); |
| 498 | void acpigen_write_not(uint8_t arg, uint8_t res); |
Cliff Huang | e608308 | 2023-01-19 21:18:23 -0800 | [diff] [blame] | 499 | void acpigen_concatenate_string_op(const char *str, uint8_t src_res, uint8_t dest_res); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 500 | void acpigen_write_debug_string(const char *str); |
Duncan Laurie | ec2e3e4 | 2020-11-03 15:19:08 -0800 | [diff] [blame] | 501 | void acpigen_write_debug_namestr(const char *str); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 502 | void acpigen_write_debug_integer(uint64_t val); |
| 503 | void acpigen_write_debug_op(uint8_t op); |
Cliff Huang | e608308 | 2023-01-19 21:18:23 -0800 | [diff] [blame] | 504 | void acpigen_write_debug_concatenate_string_op(const char *str1, uint8_t res, uint8_t tmp_res); |
Cliff Huang | 063a1b8 | 2023-02-18 00:17:26 -0800 | [diff] [blame] | 505 | void acpigen_write_debug_sprintf(const char *fmt, ...) __printf(1, 2); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 506 | void acpigen_write_if(void); |
| 507 | void acpigen_write_if_and(uint8_t arg1, uint8_t arg2); |
Duncan Laurie | 2fe7471 | 2020-06-01 17:36:56 -0700 | [diff] [blame] | 508 | void acpigen_write_if_lequal_op_op(uint8_t op, uint8_t val); |
Cliff Huang | 24f3dc8 | 2023-02-04 21:11:51 -0800 | [diff] [blame] | 509 | void acpigen_write_if_lgreater_op_op(uint8_t op1, uint8_t op2); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 510 | void acpigen_write_if_lequal_op_int(uint8_t op, uint64_t val); |
Cliff Huang | 24f3dc8 | 2023-02-04 21:11:51 -0800 | [diff] [blame] | 511 | void acpigen_write_if_lgreater_op_int(uint8_t op, uint64_t val); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 512 | void acpigen_write_if_lequal_namestr_int(const char *namestr, uint64_t val); |
Cliff Huang | 24f3dc8 | 2023-02-04 21:11:51 -0800 | [diff] [blame] | 513 | void acpigen_write_if_lgreater_namestr_int(const char *namestr, uint64_t val); |
Jakub Czapiga | 1799290 | 2022-10-27 14:12:55 +0200 | [diff] [blame] | 514 | __always_inline void acpigen_write_if_end(void) |
Jakub Czapiga | 61fcb7e | 2021-02-19 11:44:22 +0100 | [diff] [blame] | 515 | { |
| 516 | acpigen_pop_len(); |
| 517 | } |
Tim Wawrzynczak | c4ca2f6 | 2021-07-01 11:18:50 -0600 | [diff] [blame] | 518 | /* Emits If (CondRefOf(NAME)) */ |
| 519 | void acpigen_write_if_cond_ref_of(const char *namestring); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 520 | void acpigen_write_else(void); |
Duncan Laurie | 3685820 | 2020-10-06 21:01:51 +0000 | [diff] [blame] | 521 | void acpigen_write_shiftleft_op_int(uint8_t src_result, uint64_t count); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 522 | void acpigen_write_to_buffer(uint8_t src, uint8_t dst); |
| 523 | void acpigen_write_to_integer(uint8_t src, uint8_t dst); |
Aaron Durbin | 80bc091 | 2020-08-19 23:17:42 -0600 | [diff] [blame] | 524 | void acpigen_write_to_integer_from_namestring(const char *source, uint8_t dst_op); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 525 | void acpigen_write_byte_buffer(uint8_t *arr, size_t size); |
| 526 | void acpigen_write_return_byte_buffer(uint8_t *arr, size_t size); |
| 527 | void acpigen_write_return_singleton_buffer(uint8_t arg); |
Duncan Laurie | 2fe7471 | 2020-06-01 17:36:56 -0700 | [diff] [blame] | 528 | void acpigen_write_return_op(uint8_t arg); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 529 | void acpigen_write_return_byte(uint8_t arg); |
| 530 | void acpigen_write_upc(enum acpi_upc_type type); |
| 531 | void acpigen_write_pld(const struct acpi_pld *pld); |
| 532 | void acpigen_write_ADR(uint64_t adr); |
Duncan Laurie | 08a942f | 2020-04-29 12:13:14 -0700 | [diff] [blame] | 533 | struct soundwire_address; |
| 534 | void acpigen_write_ADR_soundwire_device(const struct soundwire_address *address); |
Aaron Durbin | 80bc091 | 2020-08-19 23:17:42 -0600 | [diff] [blame] | 535 | void acpigen_write_create_byte_field(uint8_t op, size_t byte_offset, const char *name); |
| 536 | void acpigen_write_create_word_field(uint8_t op, size_t byte_offset, const char *name); |
| 537 | void acpigen_write_create_dword_field(uint8_t op, size_t byte_offset, const char *name); |
| 538 | void acpigen_write_create_qword_field(uint8_t op, size_t byte_offset, const char *name); |
Michael Niewöhner | 060dc7b | 2022-05-13 00:04:19 +0200 | [diff] [blame] | 539 | void acpigen_write_field_name(const char *name, uint32_t size); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 540 | /* |
| 541 | * Generate ACPI AML code for _DSM method. |
| 542 | * This function takes as input uuid for the device, set of callbacks and |
| 543 | * argument to pass into the callbacks. Callbacks should ensure that Local0 and |
| 544 | * Local1 are left untouched. Use of Local2-Local7 is permitted in callbacks. |
Tim Wawrzynczak | d96f3a2 | 2021-07-14 15:56:57 -0600 | [diff] [blame] | 545 | * If the first callback is NULL, then a default implementation of Function 0 |
| 546 | * will be autogenerated, returning a package of bits corresponding to the |
| 547 | * function callbacks that are non-NULL. |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 548 | */ |
| 549 | void acpigen_write_dsm(const char *uuid, void (**callbacks)(void *), |
| 550 | size_t count, void *arg); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 551 | |
Tim Wawrzynczak | d96f3a2 | 2021-07-14 15:56:57 -0600 | [diff] [blame] | 552 | void acpigen_write_dsm_uuid_arr(struct dsm_uuid *ids, size_t count); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 553 | /* |
| 554 | * Generate ACPI AML code for _CPC (Continuous Performance Control). |
| 555 | * Execute the package function once to create a global table, then |
| 556 | * execute the method function within each processor object to |
| 557 | * create a method that points to the global table. |
| 558 | */ |
| 559 | void acpigen_write_CPPC_package(const struct cppc_config *config); |
| 560 | void acpigen_write_CPPC_method(void); |
| 561 | |
| 562 | /* |
| 563 | * Generate ACPI AML code for _ROM method. |
| 564 | * This function takes as input ROM data and ROM length. |
| 565 | * The ROM length has to be multiple of 4096 and has to be less |
| 566 | * than the current implementation limit of 0x40000. |
| 567 | */ |
| 568 | void acpigen_write_rom(void *bios, const size_t length); |
| 569 | /* |
| 570 | * Generate ACPI AML code for OperationRegion |
| 571 | * This function takes input region name, region space, region offset & region |
| 572 | * length. |
| 573 | */ |
Duncan Laurie | 3502960 | 2020-10-09 17:50:25 +0000 | [diff] [blame] | 574 | void acpigen_write_opregion(const struct opregion *opreg); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 575 | /* |
| 576 | * Generate ACPI AML code for Mutex |
| 577 | * This function takes mutex name and initial value. |
| 578 | */ |
| 579 | void acpigen_write_mutex(const char *name, const uint8_t flags); |
| 580 | /* |
| 581 | * Generate ACPI AML code for Acquire |
| 582 | * This function takes mutex name and privilege value. |
| 583 | */ |
| 584 | void acpigen_write_acquire(const char *name, const uint16_t val); |
| 585 | /* |
| 586 | * Generate ACPI AML code for Release |
| 587 | * This function takes mutex name. |
| 588 | */ |
| 589 | void acpigen_write_release(const char *name); |
| 590 | /* |
| 591 | * Generate ACPI AML code for Field |
| 592 | * This function takes input region name, fieldlist, count & flags. |
| 593 | */ |
| 594 | void acpigen_write_field(const char *name, const struct fieldlist *l, size_t count, |
| 595 | uint8_t flags); |
| 596 | /* |
| 597 | * Generate ACPI AML code for IndexField |
| 598 | * This function takes input index name, data name, fieldlist, count & flags. |
| 599 | */ |
| 600 | void acpigen_write_indexfield(const char *idx, const char *data, |
| 601 | struct fieldlist *l, size_t count, uint8_t flags); |
| 602 | |
Angel Pons | afd268a | 2021-10-17 13:35:23 +0200 | [diff] [blame] | 603 | int get_cst_entries(const acpi_cstate_t **); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 604 | |
| 605 | /* |
Duncan Laurie | 2fe7471 | 2020-06-01 17:36:56 -0700 | [diff] [blame] | 606 | * Get element from package into specified destination op: |
Duncan Laurie | ec2e3e4 | 2020-11-03 15:19:08 -0800 | [diff] [blame] | 607 | * <dest_op> = DeRefOf (<package_op>[<element>]) |
Duncan Laurie | 2fe7471 | 2020-06-01 17:36:56 -0700 | [diff] [blame] | 608 | * |
| 609 | * Example: |
| 610 | * acpigen_get_package_op_element(ARG0_OP, 0, LOCAL0_OP) |
| 611 | * Local0 = DeRefOf (Arg0[0]) |
| 612 | */ |
| 613 | void acpigen_get_package_op_element(uint8_t package_op, unsigned int element, uint8_t dest_op); |
| 614 | |
Duncan Laurie | ec2e3e4 | 2020-11-03 15:19:08 -0800 | [diff] [blame] | 615 | /* Set element of package op to specified op: DeRefOf (<package>[<element>]) = <src> */ |
| 616 | void acpigen_set_package_op_element_int(uint8_t package_op, unsigned int element, uint64_t src); |
| 617 | |
| 618 | /* Get element from package to specified op: <dest_op> = <package>[<element>] */ |
| 619 | void acpigen_get_package_element(const char *package, unsigned int element, uint8_t dest_op); |
| 620 | |
| 621 | /* Set element of package to specified op: <package>[<element>] = <src> */ |
| 622 | void acpigen_set_package_element_int(const char *package, unsigned int element, uint64_t src); |
| 623 | |
| 624 | /* Set element of package to specified namestr: <package>[<element>] = <src> */ |
| 625 | void acpigen_set_package_element_namestr(const char *package, unsigned int element, |
| 626 | const char *src); |
| 627 | |
| 628 | /* |
| 629 | * Delay up to wait_ms milliseconds until the provided name matches the expected value. |
| 630 | * If wait_ms is >= 32ms then it will wait in 16ms chunks. This function uses LOCAL7_OP. |
| 631 | */ |
| 632 | void acpigen_write_delay_until_namestr_int(uint32_t wait_ms, const char *name, uint64_t value); |
| 633 | |
Duncan Laurie | 2fe7471 | 2020-06-01 17:36:56 -0700 | [diff] [blame] | 634 | /* |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 635 | * Soc-implemented functions for generating ACPI AML code for GPIO handling. All |
| 636 | * these functions are expected to use only Local5, Local6 and Local7 |
| 637 | * variables. If the functions call into another ACPI method, then there is no |
| 638 | * restriction on the use of Local variables. In case of get/read functions, |
| 639 | * return value is expected to be stored in Local0 variable. |
| 640 | * |
| 641 | * All functions return 0 on success and -1 on error. |
| 642 | */ |
| 643 | |
| 644 | /* Generate ACPI AML code to return Rx value of GPIO in Local0. */ |
| 645 | int acpigen_soc_read_rx_gpio(unsigned int gpio_num); |
| 646 | |
| 647 | /* Generate ACPI AML code to return Tx value of GPIO in Local0. */ |
| 648 | int acpigen_soc_get_tx_gpio(unsigned int gpio_num); |
| 649 | |
| 650 | /* Generate ACPI AML code to set Tx value of GPIO to 1. */ |
| 651 | int acpigen_soc_set_tx_gpio(unsigned int gpio_num); |
| 652 | |
| 653 | /* Generate ACPI AML code to set Tx value of GPIO to 0. */ |
| 654 | int acpigen_soc_clear_tx_gpio(unsigned int gpio_num); |
| 655 | |
| 656 | /* |
| 657 | * Helper functions for enabling/disabling Tx GPIOs based on the GPIO |
| 658 | * polarity. These functions end up calling acpigen_soc_{set,clear}_tx_gpio to |
| 659 | * make callbacks into SoC acpigen code. |
| 660 | * |
| 661 | * Returns 0 on success and -1 on error. |
| 662 | */ |
Duncan Laurie | 30c3f91 | 2020-10-09 04:48:53 +0000 | [diff] [blame] | 663 | int acpigen_enable_tx_gpio(const struct acpi_gpio *gpio); |
| 664 | int acpigen_disable_tx_gpio(const struct acpi_gpio *gpio); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 665 | |
| 666 | /* |
| 667 | * Helper function for getting a RX GPIO value based on the GPIO polarity. |
| 668 | * The return value is stored in Local0 variable. |
| 669 | * This function ends up calling acpigen_soc_get_rx_gpio to make callbacks |
| 670 | * into SoC acpigen code |
| 671 | */ |
Duncan Laurie | 30c3f91 | 2020-10-09 04:48:53 +0000 | [diff] [blame] | 672 | void acpigen_get_rx_gpio(const struct acpi_gpio *gpio); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 673 | |
Duncan Laurie | 2fe7471 | 2020-06-01 17:36:56 -0700 | [diff] [blame] | 674 | /* |
| 675 | * Helper function for getting a TX GPIO value based on the GPIO polarity. |
| 676 | * The return value is stored in Local0 variable. |
| 677 | * This function ends up calling acpigen_soc_get_tx_gpio to make callbacks |
| 678 | * into SoC acpigen code |
| 679 | */ |
Duncan Laurie | 30c3f91 | 2020-10-09 04:48:53 +0000 | [diff] [blame] | 680 | void acpigen_get_tx_gpio(const struct acpi_gpio *gpio); |
Duncan Laurie | 2fe7471 | 2020-06-01 17:36:56 -0700 | [diff] [blame] | 681 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 682 | /* refer to ACPI 6.4.3.5.3 Word Address Space Descriptor section for details */ |
| 683 | void acpigen_resource_word(u16 res_type, u16 gen_flags, u16 type_flags, u16 gran, |
| 684 | u16 range_min, u16 range_max, u16 translation, u16 length); |
| 685 | /* refer to ACPI 6.4.3.5.2 DWord Address Space Descriptor section for details */ |
| 686 | void acpigen_resource_dword(u16 res_type, u16 gen_flags, u16 type_flags, |
| 687 | u32 gran, u32 range_min, u32 range_max, u32 translation, u32 length); |
| 688 | /* refer to ACPI 6.4.3.5.1 QWord Address Space Descriptor section for details */ |
| 689 | void acpigen_resource_qword(u16 res_type, u16 gen_flags, u16 type_flags, |
| 690 | u64 gran, u64 range_min, u64 range_max, u64 translation, u64 length); |
| 691 | |
Felix Held | 0fdede0 | 2023-05-27 01:02:37 +0200 | [diff] [blame] | 692 | void acpigen_resource_producer_bus_number(u16 bus_base, u16 bus_limit); |
| 693 | void acpigen_resource_producer_io(u16 io_base, u16 io_limit); |
| 694 | void acpigen_resource_producer_mmio(u64 mmio_base, u64 mmio_limit, u16 type_flags); |
Arthur Heymans | 62f788e | 2023-11-21 18:49:33 +0100 | [diff] [blame] | 695 | void acpigen_resource_consumer_mmio(u64 mmio_base, u64 mmio_limit, u16 type_flags); |
Felix Held | 5a82f0d | 2023-05-09 16:10:35 +0200 | [diff] [blame] | 696 | |
Tim Wawrzynczak | f694502 | 2020-06-04 15:18:47 -0600 | [diff] [blame] | 697 | /* Emits Notify(namestr, value) */ |
| 698 | void acpigen_notify(const char *namestr, int value); |
| 699 | |
Arthur Heymans | 0eb5974 | 2023-04-25 16:23:37 +0200 | [diff] [blame] | 700 | /* Create a namespace \OSFG to override the enabled sleep states */ |
| 701 | void acpigen_ssdt_override_sleep_states(bool enable_s1, bool enable_s2, bool enable_s3, |
| 702 | bool enable_s4); |
| 703 | |
Furquan Shaikh | 56eafbb | 2020-04-30 18:38:55 -0700 | [diff] [blame] | 704 | #endif /* __ACPI_ACPIGEN_H__ */ |