Felix Held | 18b51e9 | 2021-05-08 01:30:30 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <acpi/acpigen.h> |
| 4 | #include <amdblocks/alib.h> |
| 5 | #include <types.h> |
| 6 | |
Felix Held | 2d0bf34 | 2021-05-12 01:42:37 +0200 | [diff] [blame] | 7 | static void acpigen_dptc_call_alib(const char *buf_name, uint8_t *buffer, size_t size) |
Felix Held | 18b51e9 | 2021-05-08 01:30:30 +0200 | [diff] [blame] | 8 | { |
| 9 | /* Name (buf_name, Buffer(size) {...} */ |
| 10 | acpigen_write_name(buf_name); |
| 11 | acpigen_write_byte_buffer(buffer, size); |
| 12 | |
| 13 | /* \_SB.ALIB(0xc, buf_name) */ |
| 14 | acpigen_emit_namestring("\\_SB.ALIB"); |
| 15 | acpigen_write_integer(ALIB_FUNCTION_DYNAMIC_POWER_THERMAL_CONFIG); |
| 16 | acpigen_emit_namestring(buf_name); |
| 17 | } |
Felix Held | 2d0bf34 | 2021-05-12 01:42:37 +0200 | [diff] [blame] | 18 | |
Tim Van Patten | 9244358 | 2022-08-23 16:06:33 -0600 | [diff] [blame] | 19 | void acpigen_write_alib_dptc_default(uint8_t *default_param, size_t default_param_len) |
Felix Held | 2d0bf34 | 2021-05-12 01:42:37 +0200 | [diff] [blame] | 20 | { |
| 21 | /* Scope (\_SB) */ |
| 22 | acpigen_write_scope("\\_SB"); |
| 23 | |
Tim Van Patten | 9244358 | 2022-08-23 16:06:33 -0600 | [diff] [blame] | 24 | /* Default (Unthrottled) Mode */ |
| 25 | /* Scope (\_SB) |
| 26 | * { |
| 27 | * Method (DDEF, 0, Serialized) |
| 28 | * { |
| 29 | * Debug = "DPTC: Using normal SOC DPTC Settings." |
| 30 | * Name (DEFB, Buffer (0x25) |
| 31 | * { |
| 32 | * ... |
| 33 | * }) |
| 34 | * \_SB.ALIB |
| 35 | * 0x0C |
| 36 | * DEFB |
| 37 | * } |
| 38 | * } |
| 39 | */ |
| 40 | acpigen_write_method_serialized("DDEF", 0); |
| 41 | acpigen_write_debug_string("DPTC: Using normal SOC DPTC Settings."); |
Felix Held | 2d0bf34 | 2021-05-12 01:42:37 +0200 | [diff] [blame] | 42 | acpigen_dptc_call_alib("DEFB", default_param, default_param_len); |
Tim Van Patten | 9244358 | 2022-08-23 16:06:33 -0600 | [diff] [blame] | 43 | acpigen_write_method_end(); |
Felix Held | 2d0bf34 | 2021-05-12 01:42:37 +0200 | [diff] [blame] | 44 | |
Tim Van Patten | 9244358 | 2022-08-23 16:06:33 -0600 | [diff] [blame] | 45 | acpigen_write_scope_end(); |
| 46 | } |
Felix Held | 2d0bf34 | 2021-05-12 01:42:37 +0200 | [diff] [blame] | 47 | |
Tim Van Patten | a90aebb | 2022-08-16 12:09:23 -0600 | [diff] [blame] | 48 | void acpigen_write_alib_dptc_no_battery(uint8_t *no_battery_param, size_t no_battery_param_len) |
| 49 | { |
| 50 | /* Scope (\_SB) */ |
| 51 | acpigen_write_scope("\\_SB"); |
| 52 | |
| 53 | /* Low/No Battery Mode */ |
| 54 | /* Scope (\_SB) |
| 55 | * { |
| 56 | * Method (DTHL, 0, Serialized) |
| 57 | * { |
| 58 | * Debug = "DPTC: Using low/no battery mode SOC DPTC settings." |
| 59 | * Name (THTL, Buffer (0x25) |
| 60 | * { |
| 61 | * ... |
| 62 | * }) |
| 63 | * \_SB.ALIB |
| 64 | * 0x0C |
| 65 | * THTL |
| 66 | * } |
| 67 | * } |
| 68 | */ |
| 69 | acpigen_write_method_serialized("DTHL", 0); |
| 70 | acpigen_write_debug_string("DPTC: Using low/no battery mode SOC DPTC settings."); |
| 71 | acpigen_dptc_call_alib("THTL", no_battery_param, no_battery_param_len); |
| 72 | acpigen_write_method_end(); |
| 73 | |
| 74 | acpigen_write_scope_end(); |
| 75 | } |
| 76 | |
Tim Van Patten | 9244358 | 2022-08-23 16:06:33 -0600 | [diff] [blame] | 77 | void acpigen_write_alib_dptc_tablet(uint8_t *tablet_param, size_t tablet_param_len) |
| 78 | { |
| 79 | /* Scope (\_SB) */ |
| 80 | acpigen_write_scope("\\_SB"); |
| 81 | |
| 82 | /* Tablet Mode */ |
| 83 | /* Scope (\_SB) |
| 84 | * { |
| 85 | * Method (DTAB, 0, Serialized) |
| 86 | * { |
| 87 | * Debug = "DPTC: Using tablet mode SOC DPTC Settings." |
| 88 | * Name (TABB, Buffer (0x25) |
| 89 | * { |
| 90 | * ... |
| 91 | * }) |
| 92 | * \_SB.ALIB |
| 93 | * 0x0C |
| 94 | * TABB |
| 95 | * } |
| 96 | * } |
| 97 | */ |
| 98 | acpigen_write_method_serialized("DTAB", 0); |
| 99 | acpigen_write_debug_string("DPTC: Using tablet mode SOC DPTC Settings."); |
| 100 | acpigen_dptc_call_alib("TABB", tablet_param, tablet_param_len); |
| 101 | acpigen_write_method_end(); |
| 102 | |
| 103 | acpigen_write_scope_end(); |
Felix Held | 2d0bf34 | 2021-05-12 01:42:37 +0200 | [diff] [blame] | 104 | } |