Simon Glass | 98528d4 | 2020-07-07 13:11:42 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Core ACPI (Advanced Configuration and Power Interface) support |
| 4 | * |
| 5 | * Copyright 2019 Google LLC |
| 6 | * |
| 7 | * Modified from coreboot file acpigen.h |
| 8 | */ |
| 9 | |
| 10 | #ifndef __ACPI_ACPIGEN_H |
| 11 | #define __ACPI_ACPIGEN_H |
| 12 | |
| 13 | #include <linux/types.h> |
| 14 | |
| 15 | struct acpi_ctx; |
Simon Glass | 837127f | 2020-07-07 21:32:11 -0600 | [diff] [blame^] | 16 | struct acpi_gen_regaddr; |
Simon Glass | 8a20076 | 2020-07-07 13:12:01 -0600 | [diff] [blame] | 17 | struct acpi_gpio; |
Simon Glass | 98528d4 | 2020-07-07 13:11:42 -0600 | [diff] [blame] | 18 | |
Simon Glass | 0f27763 | 2020-07-07 13:11:50 -0600 | [diff] [blame] | 19 | /* Top 4 bits of the value used to indicate a three-byte length value */ |
| 20 | #define ACPI_PKG_LEN_3_BYTES 0x80 |
| 21 | |
Simon Glass | 9238fac | 2020-07-07 13:11:59 -0600 | [diff] [blame] | 22 | #define ACPI_METHOD_NARGS_MASK 0x7 |
| 23 | #define ACPI_METHOD_SERIALIZED_MASK BIT(3) |
| 24 | |
Simon Glass | 837127f | 2020-07-07 21:32:11 -0600 | [diff] [blame^] | 25 | #define ACPI_END_TAG 0x79 |
| 26 | |
Simon Glass | edc2680 | 2020-07-07 13:11:51 -0600 | [diff] [blame] | 27 | /* ACPI Op/Prefix codes */ |
| 28 | enum { |
Simon Glass | 8715ce0 | 2020-07-07 13:11:52 -0600 | [diff] [blame] | 29 | ZERO_OP = 0x00, |
| 30 | ONE_OP = 0x01, |
Simon Glass | 0dc3d51 | 2020-07-07 13:11:54 -0600 | [diff] [blame] | 31 | NAME_OP = 0x08, |
Simon Glass | 8715ce0 | 2020-07-07 13:11:52 -0600 | [diff] [blame] | 32 | BYTE_PREFIX = 0x0a, |
| 33 | WORD_PREFIX = 0x0b, |
| 34 | DWORD_PREFIX = 0x0c, |
Simon Glass | 45d6d95 | 2020-07-07 13:11:53 -0600 | [diff] [blame] | 35 | STRING_PREFIX = 0x0d, |
Simon Glass | 8715ce0 | 2020-07-07 13:11:52 -0600 | [diff] [blame] | 36 | QWORD_PREFIX = 0x0e, |
Simon Glass | 6fcdaf1 | 2020-07-07 21:32:10 -0600 | [diff] [blame] | 37 | SCOPE_OP = 0x10, |
Simon Glass | 48342b0 | 2020-07-07 13:11:55 -0600 | [diff] [blame] | 38 | BUFFER_OP = 0x11, |
Simon Glass | edc2680 | 2020-07-07 13:11:51 -0600 | [diff] [blame] | 39 | PACKAGE_OP = 0x12, |
Simon Glass | 9238fac | 2020-07-07 13:11:59 -0600 | [diff] [blame] | 40 | METHOD_OP = 0x14, |
| 41 | SLEEP_OP = 0x22, |
Simon Glass | 0dc3d51 | 2020-07-07 13:11:54 -0600 | [diff] [blame] | 42 | DUAL_NAME_PREFIX = 0x2e, |
| 43 | MULTI_NAME_PREFIX = 0x2f, |
Simon Glass | 9238fac | 2020-07-07 13:11:59 -0600 | [diff] [blame] | 44 | DEBUG_OP = 0x31, |
| 45 | EXT_OP_PREFIX = 0x5b, |
Simon Glass | c993ff7 | 2020-07-07 13:11:56 -0600 | [diff] [blame] | 46 | ROOT_PREFIX = 0x5c, |
Simon Glass | 9238fac | 2020-07-07 13:11:59 -0600 | [diff] [blame] | 47 | LOCAL0_OP = 0x60, |
| 48 | LOCAL1_OP = 0x61, |
| 49 | LOCAL2_OP = 0x62, |
| 50 | LOCAL3_OP = 0x63, |
| 51 | LOCAL4_OP = 0x64, |
| 52 | LOCAL5_OP = 0x65, |
| 53 | LOCAL6_OP = 0x66, |
| 54 | LOCAL7_OP = 0x67, |
| 55 | STORE_OP = 0x70, |
| 56 | AND_OP = 0x7b, |
| 57 | OR_OP = 0x7d, |
| 58 | NOT_OP = 0x80, |
Simon Glass | d0f7d9b | 2020-07-07 13:12:00 -0600 | [diff] [blame] | 59 | POWER_RES_OP = 0x84, |
Simon Glass | 9238fac | 2020-07-07 13:11:59 -0600 | [diff] [blame] | 60 | RETURN_OP = 0xa4, |
Simon Glass | edc2680 | 2020-07-07 13:11:51 -0600 | [diff] [blame] | 61 | }; |
| 62 | |
Simon Glass | 98528d4 | 2020-07-07 13:11:42 -0600 | [diff] [blame] | 63 | /** |
| 64 | * acpigen_get_current() - Get the current ACPI code output pointer |
| 65 | * |
| 66 | * @ctx: ACPI context pointer |
| 67 | * @return output pointer |
| 68 | */ |
| 69 | u8 *acpigen_get_current(struct acpi_ctx *ctx); |
| 70 | |
| 71 | /** |
| 72 | * acpigen_emit_byte() - Emit a byte to the ACPI code |
| 73 | * |
| 74 | * @ctx: ACPI context pointer |
| 75 | * @data: Value to output |
| 76 | */ |
| 77 | void acpigen_emit_byte(struct acpi_ctx *ctx, uint data); |
| 78 | |
| 79 | /** |
| 80 | * acpigen_emit_word() - Emit a 16-bit word to the ACPI code |
| 81 | * |
| 82 | * @ctx: ACPI context pointer |
| 83 | * @data: Value to output |
| 84 | */ |
| 85 | void acpigen_emit_word(struct acpi_ctx *ctx, uint data); |
| 86 | |
| 87 | /** |
| 88 | * acpigen_emit_dword() - Emit a 32-bit 'double word' to the ACPI code |
| 89 | * |
| 90 | * @ctx: ACPI context pointer |
| 91 | * @data: Value to output |
| 92 | */ |
| 93 | void acpigen_emit_dword(struct acpi_ctx *ctx, uint data); |
| 94 | |
Simon Glass | 071c4a5 | 2020-07-07 13:11:45 -0600 | [diff] [blame] | 95 | /** |
| 96 | * acpigen_emit_stream() - Emit a stream of bytes |
| 97 | * |
| 98 | * @ctx: ACPI context pointer |
| 99 | * @data: Data to output |
| 100 | * @size: Size of data in bytes |
| 101 | */ |
| 102 | void acpigen_emit_stream(struct acpi_ctx *ctx, const char *data, int size); |
| 103 | |
| 104 | /** |
| 105 | * acpigen_emit_string() - Emit a string |
| 106 | * |
| 107 | * Emit a string with a null terminator |
| 108 | * |
| 109 | * @ctx: ACPI context pointer |
| 110 | * @str: String to output, or NULL for an empty string |
| 111 | */ |
| 112 | void acpigen_emit_string(struct acpi_ctx *ctx, const char *str); |
| 113 | |
Simon Glass | 0f27763 | 2020-07-07 13:11:50 -0600 | [diff] [blame] | 114 | /** |
| 115 | * acpigen_write_len_f() - Write a 'forward' length placeholder |
| 116 | * |
| 117 | * This adds space for a length value in the ACPI stream and pushes the current |
| 118 | * position (before the length) on the stack. After calling this you can write |
| 119 | * some data and then call acpigen_pop_len() to update the length value. |
| 120 | * |
| 121 | * Usage: |
| 122 | * |
| 123 | * acpigen_write_len_f() ------\ |
| 124 | * acpigen_write...() | |
| 125 | * acpigen_write...() | |
| 126 | * acpigen_write_len_f() --\ | |
| 127 | * acpigen_write...() | | |
| 128 | * acpigen_write...() | | |
| 129 | * acpigen_pop_len() ------/ | |
| 130 | * acpigen_write...() | |
| 131 | * acpigen_pop_len() ----------/ |
| 132 | * |
| 133 | * See ACPI 6.3 section 20.2.4 Package Length Encoding |
| 134 | * |
| 135 | * This implementation always uses a 3-byte packet length for simplicity. It |
| 136 | * could be adjusted to support other lengths. |
| 137 | * |
| 138 | * @ctx: ACPI context pointer |
| 139 | */ |
| 140 | void acpigen_write_len_f(struct acpi_ctx *ctx); |
| 141 | |
| 142 | /** |
| 143 | * acpigen_pop_len() - Update the previously stacked length placeholder |
| 144 | * |
| 145 | * Call this after the data for the block has been written. It updates the |
| 146 | * top length value in the stack and pops it off. |
| 147 | * |
| 148 | * @ctx: ACPI context pointer |
| 149 | */ |
| 150 | void acpigen_pop_len(struct acpi_ctx *ctx); |
| 151 | |
Simon Glass | edc2680 | 2020-07-07 13:11:51 -0600 | [diff] [blame] | 152 | /** |
| 153 | * acpigen_write_package() - Start writing a package |
| 154 | * |
| 155 | * A package collects together a number of elements in the ACPI code. To write |
| 156 | * a package use: |
| 157 | * |
| 158 | * acpigen_write_package(ctx, 3); |
| 159 | * ...write things |
| 160 | * acpigen_pop_len() |
| 161 | * |
| 162 | * If you don't know the number of elements in advance, acpigen_write_package() |
| 163 | * returns a pointer to the value so you can update it later: |
| 164 | * |
| 165 | * char *num_elements = acpigen_write_package(ctx, 0); |
| 166 | * ...write things |
| 167 | * *num_elements += 1; |
| 168 | * ...write things |
| 169 | * *num_elements += 1; |
| 170 | * acpigen_pop_len() |
| 171 | * |
| 172 | * @ctx: ACPI context pointer |
| 173 | * @nr_el: Number of elements (0 if not known) |
| 174 | * @returns pointer to the number of elements, which can be updated by the |
| 175 | * caller if needed |
| 176 | */ |
| 177 | char *acpigen_write_package(struct acpi_ctx *ctx, int nr_el); |
| 178 | |
Simon Glass | 8715ce0 | 2020-07-07 13:11:52 -0600 | [diff] [blame] | 179 | /** |
Simon Glass | d6814e2 | 2020-07-07 21:32:09 -0600 | [diff] [blame] | 180 | * acpigen_write_byte() - Write a byte |
| 181 | * |
| 182 | * @ctx: ACPI context pointer |
| 183 | * @data: Value to write |
| 184 | */ |
| 185 | void acpigen_write_byte(struct acpi_ctx *ctx, unsigned int data); |
| 186 | |
| 187 | /** |
| 188 | * acpigen_write_word() - Write a word |
| 189 | * |
| 190 | * @ctx: ACPI context pointer |
| 191 | * @data: Value to write |
| 192 | */ |
| 193 | void acpigen_write_word(struct acpi_ctx *ctx, unsigned int data); |
| 194 | |
| 195 | /** |
| 196 | * acpigen_write_dword() - Write a dword |
| 197 | * |
| 198 | * @ctx: ACPI context pointer |
| 199 | * @data: Value to write |
| 200 | */ |
| 201 | void acpigen_write_dword(struct acpi_ctx *ctx, unsigned int data); |
| 202 | |
| 203 | /** |
| 204 | * acpigen_write_qword() - Write a qword |
| 205 | * |
| 206 | * @ctx: ACPI context pointer |
| 207 | * @data: Value to write |
| 208 | */ |
| 209 | void acpigen_write_qword(struct acpi_ctx *ctx, u64 data); |
| 210 | |
| 211 | /** |
| 212 | * acpigen_write_zero() - Write zero |
| 213 | * |
| 214 | * @ctx: ACPI context pointer |
| 215 | */ |
| 216 | void acpigen_write_zero(struct acpi_ctx *ctx); |
| 217 | |
| 218 | /** |
| 219 | * acpigen_write_one() - Write one |
| 220 | * |
| 221 | * @ctx: ACPI context pointer |
| 222 | */ |
| 223 | void acpigen_write_one(struct acpi_ctx *ctx); |
| 224 | |
| 225 | /** |
Simon Glass | 8715ce0 | 2020-07-07 13:11:52 -0600 | [diff] [blame] | 226 | * acpigen_write_integer() - Write an integer |
| 227 | * |
| 228 | * This writes an operation (BYTE_OP, WORD_OP, DWORD_OP, QWORD_OP depending on |
| 229 | * the integer size) and an integer value. Note that WORD means 16 bits in ACPI. |
| 230 | * |
| 231 | * @ctx: ACPI context pointer |
| 232 | * @data: Integer to write |
| 233 | */ |
| 234 | void acpigen_write_integer(struct acpi_ctx *ctx, u64 data); |
| 235 | |
Simon Glass | 45d6d95 | 2020-07-07 13:11:53 -0600 | [diff] [blame] | 236 | /** |
| 237 | * acpigen_write_string() - Write a string |
| 238 | * |
| 239 | * This writes a STRING_PREFIX followed by a null-terminated string |
| 240 | * |
| 241 | * @ctx: ACPI context pointer |
| 242 | * @str: String to write |
| 243 | */ |
| 244 | void acpigen_write_string(struct acpi_ctx *ctx, const char *str); |
Simon Glass | 0dc3d51 | 2020-07-07 13:11:54 -0600 | [diff] [blame] | 245 | |
| 246 | /** |
| 247 | * acpigen_emit_namestring() - Emit an ACPI name |
| 248 | * |
| 249 | * This writes out an ACPI name or path in the required special format. It does |
| 250 | * not add the NAME_OP prefix. |
| 251 | * |
| 252 | * @ctx: ACPI context pointer |
| 253 | * @namepath: Name / path to emit |
| 254 | */ |
| 255 | void acpigen_emit_namestring(struct acpi_ctx *ctx, const char *namepath); |
| 256 | |
| 257 | /** |
| 258 | * acpigen_write_name() - Write out an ACPI name |
| 259 | * |
| 260 | * This writes out an ACPI name or path in the required special format with a |
| 261 | * NAME_OP prefix. |
| 262 | * |
| 263 | * @ctx: ACPI context pointer |
| 264 | * @namepath: Name / path to emit |
| 265 | */ |
| 266 | void acpigen_write_name(struct acpi_ctx *ctx, const char *namepath); |
Simon Glass | 48342b0 | 2020-07-07 13:11:55 -0600 | [diff] [blame] | 267 | |
| 268 | /** |
Simon Glass | 6fcdaf1 | 2020-07-07 21:32:10 -0600 | [diff] [blame] | 269 | * acpigen_write_scope() - Write a scope |
| 270 | * |
| 271 | * @ctx: ACPI context pointer |
| 272 | * @scope: Scope to write (e.g. "\\_SB.ABCD") |
| 273 | */ |
| 274 | void acpigen_write_scope(struct acpi_ctx *ctx, const char *scope); |
| 275 | |
| 276 | /** |
Simon Glass | 48342b0 | 2020-07-07 13:11:55 -0600 | [diff] [blame] | 277 | * acpigen_write_uuid() - Write a UUID |
| 278 | * |
| 279 | * This writes out a UUID in the format used by ACPI, with a BUFFER_OP prefix. |
| 280 | * |
| 281 | * @ctx: ACPI context pointer |
| 282 | * @uuid: UUID to write in the form aabbccdd-eeff-gghh-iijj-kkllmmnnoopp |
| 283 | * @return 0 if OK, -EINVAL if the format is incorrect |
| 284 | */ |
| 285 | int acpigen_write_uuid(struct acpi_ctx *ctx, const char *uuid); |
| 286 | |
Simon Glass | 9238fac | 2020-07-07 13:11:59 -0600 | [diff] [blame] | 287 | /** |
| 288 | * acpigen_emit_ext_op() - Emit an extended op with the EXT_OP_PREFIX prefix |
| 289 | * |
| 290 | * @ctx: ACPI context pointer |
| 291 | * @op: Operation code (e.g. SLEEP_OP) |
| 292 | */ |
| 293 | void acpigen_emit_ext_op(struct acpi_ctx *ctx, uint op); |
| 294 | |
| 295 | /** |
| 296 | * acpigen_write_method() - Write a method header |
| 297 | * |
| 298 | * @ctx: ACPI context pointer |
| 299 | * @name: Method name (4 characters) |
| 300 | * @nargs: Number of method arguments (0 if none) |
| 301 | */ |
| 302 | void acpigen_write_method(struct acpi_ctx *ctx, const char *name, int nargs); |
| 303 | |
| 304 | /** |
| 305 | * acpigen_write_method_serialized() - Write a method header |
| 306 | * |
| 307 | * This sets the 'serialized' flag so that the method is thread-safe |
| 308 | * |
| 309 | * @ctx: ACPI context pointer |
| 310 | * @name: Method name (4 characters) |
| 311 | * @nargs: Number of method arguments (0 if none) |
| 312 | */ |
| 313 | void acpigen_write_method_serialized(struct acpi_ctx *ctx, const char *name, |
| 314 | int nargs); |
| 315 | |
| 316 | /** |
| 317 | * acpigen_write_sta() - Write a _STA method |
| 318 | * |
| 319 | * @ctx: ACPI context pointer |
| 320 | * @status: Status value to return |
| 321 | */ |
| 322 | void acpigen_write_sta(struct acpi_ctx *ctx, uint status); |
| 323 | |
| 324 | /** |
Simon Glass | 837127f | 2020-07-07 21:32:11 -0600 | [diff] [blame^] | 325 | * acpigen_write_resourcetemplate_header() - Write a ResourceTemplate header |
| 326 | * |
| 327 | * @ctx: ACPI context pointer |
| 328 | */ |
| 329 | void acpigen_write_resourcetemplate_header(struct acpi_ctx *ctx); |
| 330 | |
| 331 | /** |
| 332 | * acpigen_write_resourcetemplate_footer() - Write a ResourceTemplate footer |
| 333 | * |
| 334 | * @ctx: ACPI context pointer |
| 335 | */ |
| 336 | void acpigen_write_resourcetemplate_footer(struct acpi_ctx *ctx); |
| 337 | |
| 338 | /** |
| 339 | * acpigen_write_register_resource() - Write a register resource |
| 340 | * |
| 341 | * This writes a header, the address information and a footer |
| 342 | * |
| 343 | * @ctx: ACPI context pointer |
| 344 | * @addr: Address to write |
| 345 | */ |
| 346 | void acpigen_write_register_resource(struct acpi_ctx *ctx, |
| 347 | const struct acpi_gen_regaddr *addr); |
| 348 | |
| 349 | /** |
Simon Glass | 9238fac | 2020-07-07 13:11:59 -0600 | [diff] [blame] | 350 | * acpigen_write_sleep() - Write a sleep operation |
| 351 | * |
| 352 | * @ctx: ACPI context pointer |
| 353 | * @sleep_ms: Number of milliseconds to sleep for |
| 354 | */ |
| 355 | void acpigen_write_sleep(struct acpi_ctx *ctx, u64 sleep_ms); |
| 356 | |
| 357 | /** |
| 358 | * acpigen_write_store() - Write a store operation |
| 359 | * |
| 360 | * @ctx: ACPI context pointer |
| 361 | */ |
| 362 | void acpigen_write_store(struct acpi_ctx *ctx); |
| 363 | |
| 364 | /** |
| 365 | * acpigen_write_debug_string() - Write a debug string |
| 366 | * |
| 367 | * This writes a debug operation with an associated string |
| 368 | * |
| 369 | * @ctx: ACPI context pointer |
| 370 | * @str: String to write |
| 371 | */ |
| 372 | void acpigen_write_debug_string(struct acpi_ctx *ctx, const char *str); |
| 373 | |
| 374 | /** |
| 375 | * acpigen_write_or() - Write a bitwise OR operation |
| 376 | * |
| 377 | * res = arg1 | arg2 |
| 378 | * |
| 379 | * @ctx: ACPI context pointer |
| 380 | * @arg1: ACPI opcode for operand 1 (e.g. LOCAL0_OP) |
| 381 | * @arg2: ACPI opcode for operand 2 (e.g. LOCAL1_OP) |
| 382 | * @res: ACPI opcode for result (e.g. LOCAL2_OP) |
| 383 | */ |
| 384 | void acpigen_write_or(struct acpi_ctx *ctx, u8 arg1, u8 arg2, u8 res); |
| 385 | |
| 386 | /** |
| 387 | * acpigen_write_and() - Write a bitwise AND operation |
| 388 | * |
| 389 | * res = arg1 & arg2 |
| 390 | * |
| 391 | * @ctx: ACPI context pointer |
| 392 | * @arg1: ACPI opcode for operand 1 (e.g. LOCAL0_OP) |
| 393 | * @arg2: ACPI opcode for operand 2 (e.g. LOCAL1_OP) |
| 394 | * @res: ACPI opcode for result (e.g. LOCAL2_OP) |
| 395 | */ |
| 396 | void acpigen_write_and(struct acpi_ctx *ctx, u8 arg1, u8 arg2, u8 res); |
| 397 | |
| 398 | /** |
| 399 | * acpigen_write_not() - Write a bitwise NOT operation |
| 400 | * |
| 401 | * res = ~arg1 |
| 402 | * |
| 403 | * @ctx: ACPI context pointer |
| 404 | * @arg: ACPI opcode for operand (e.g. LOCAL0_OP) |
| 405 | * @res: ACPI opcode for result (e.g. LOCAL2_OP) |
| 406 | */ |
| 407 | void acpigen_write_not(struct acpi_ctx *ctx, u8 arg, u8 res); |
| 408 | |
Simon Glass | d0f7d9b | 2020-07-07 13:12:00 -0600 | [diff] [blame] | 409 | /** |
| 410 | * acpigen_write_power_res() - Write a power resource |
| 411 | * |
| 412 | * Name (_PRx, Package(One) { name }) |
| 413 | * ... |
| 414 | * PowerResource (name, level, order) |
| 415 | * |
| 416 | * The caller should fill in the rest of the power resource and then call |
| 417 | * acpigen_pop_len() to close it off |
| 418 | * |
| 419 | * @ctx: ACPI context pointer |
| 420 | * @name: Name of power resource (e.g. "PRIC") |
| 421 | * @level: Deepest sleep level that this resource must be kept on (0=S0, 3=S3) |
| 422 | * @order: Order that this must be enabled/disabled (e.g. 0) |
| 423 | * @dev_stats: List of states to define, e.g. {"_PR0", "_PR3"} |
| 424 | * @dev_states_count: Number of dev states |
| 425 | */ |
| 426 | void acpigen_write_power_res(struct acpi_ctx *ctx, const char *name, uint level, |
| 427 | uint order, const char *const dev_states[], |
| 428 | size_t dev_states_count); |
| 429 | |
Simon Glass | 8a20076 | 2020-07-07 13:12:01 -0600 | [diff] [blame] | 430 | /** |
| 431 | * acpigen_set_enable_tx_gpio() - Emit ACPI code to enable/disable a GPIO |
| 432 | * |
| 433 | * This emits code to either enable to disable a Tx GPIO. It takes account of |
| 434 | * the GPIO polarity. |
| 435 | * |
| 436 | * The code needs access to the DW0 register for the pad being used. This is |
| 437 | * provided by gpio->pin0_addr and ACPI methods must be defined for the board |
| 438 | * which can read and write the pad's DW0 register given this address: |
| 439 | * @dw0_read: takes a single argument, the DW0 address |
| 440 | * returns the DW0 value |
| 441 | * @dw0:write: takes two arguments, the DW0 address and the value to write |
| 442 | * no return value |
| 443 | * |
| 444 | * Example code (-- means comment): |
| 445 | * |
| 446 | * -- Get Pad Configuration DW0 register value |
| 447 | * Method (GPC0, 0x1, Serialized) |
| 448 | * { |
| 449 | * -- Arg0 - GPIO DW0 address |
| 450 | * Store (Arg0, Local0) |
| 451 | * OperationRegion (PDW0, SystemMemory, Local0, 4) |
| 452 | * Field (PDW0, AnyAcc, NoLock, Preserve) { |
| 453 | * TEMP, 32 |
| 454 | * } |
| 455 | * Return (TEMP) |
| 456 | * } |
| 457 | * |
| 458 | * -- Set Pad Configuration DW0 register value |
| 459 | * Method (SPC0, 0x2, Serialized) |
| 460 | * { |
| 461 | * -- Arg0 - GPIO DW0 address |
| 462 | * -- Arg1 - Value for DW0 register |
| 463 | * Store (Arg0, Local0) |
| 464 | * OperationRegion (PDW0, SystemMemory, Local0, 4) |
| 465 | * Field (PDW0, AnyAcc, NoLock, Preserve) { |
| 466 | * TEMP,32 |
| 467 | * } |
| 468 | * Store (Arg1, TEMP) |
| 469 | * } |
| 470 | * |
| 471 | * |
| 472 | * @ctx: ACPI context pointer |
| 473 | * @tx_state_val: Mask to use to toggle the TX state on the GPIO pin, e,g. |
| 474 | * PAD_CFG0_TX_STATE |
| 475 | * @dw0_read: Method name to use to read dw0, e.g. "\\_SB.GPC0" |
| 476 | * @dw0_write: Method name to use to read dw0, e.g. "\\_SB.SPC0" |
| 477 | * @gpio: GPIO to change |
| 478 | * @enable: true to enable GPIO, false to disable |
| 479 | * Returns 0 on success, -ve on error. |
| 480 | */ |
| 481 | int acpigen_set_enable_tx_gpio(struct acpi_ctx *ctx, u32 tx_state_val, |
| 482 | const char *dw0_read, const char *dw0_write, |
| 483 | struct acpi_gpio *gpio, bool enable); |
| 484 | |
Simon Glass | 98528d4 | 2020-07-07 13:11:42 -0600 | [diff] [blame] | 485 | #endif |