mb/starlabs/starlite_adl: Configure GPIO interrupt for Virtual Button
[coreboot2.git] / src / drivers / usb / acpi / intel_bluetooth.c
blob4cefcf28b6dc5fd350cda3683eb5c8420439cc01
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpigen.h>
4 #include "chip.h"
6 /*
7 * Intel Bluetooth DSM
9 * Check/Set Reset Delay (aa10f4e0-81ac-4233-abf6-3b2ac50e28d9)
10 * Arg2 == 0: Return a package with the following bit set
11 * BIT(0) Indicates whether the device supports other functions
12 * BIT(1) Check Bluetooth reset timing
14 * Arg2 == 1: Set the reset delay based on Arg3
16 * Arg2 == 3: Set the reset method based on Arg3 (Not supported by this driver)
17 * WDISABLE2 (BT_RF_KILL_N)
18 * VSEC (PCI Config Space)
21 static void check_reset_delay(void *arg)
23 acpigen_write_if_lequal_op_int(ARG1_OP, 0);
25 acpigen_write_return_singleton_buffer(0x03);
27 acpigen_write_else();
29 acpigen_write_return_singleton_buffer(0x00);
31 acpigen_pop_len();
34 static void set_reset_delay(void *arg)
36 acpigen_write_store_op_to_namestr(ARG3_OP, "RDLY");
39 static void not_supported(void *arg)
41 acpigen_write_return_singleton_buffer(0x00);
44 void (*reset_supported[])(void *) = { check_reset_delay, set_reset_delay };
45 void (*reset_unsupported[])(void *) = { not_supported };
47 void acpi_device_intel_bt(unsigned int reset_gpio, unsigned int enable_gpio, bool audio_offload)
50 * Name (RDLY, 0x69)
52 acpigen_write_name_integer("RDLY", 0x69);
55 * Method (_DSM, 4, Serialized)
56 * {
57 * If ((Arg0 == ToUUID ("aa10f4e0-81ac-4233-abf6-3b2ac50e28d9")))
58 * {
59 * If ((Arg2 == Zero))
60 * {
61 * If ((Arg1 == Zero))
62 * {
63 * Return (Buffer (One)
64 * {
65 * 0x03
66 * })
67 * }
68 * Else
69 * {
70 * Return (Buffer (One)
71 * {
72 * 0x00
73 * })
74 * }
75 * }
76 * If ((Arg2 == One))
77 * {
78 * RDLY = Arg3
79 * }
80 * Return (Zero)
81 * }
82 * Else
83 * {
84 * Return (Buffer (One)
85 * {
86 * 0x00
87 * })
88 * }
89 * }
92 struct dsm_uuid uuid_callbacks[] = {
93 DSM_UUID("aa10f4e0-81ac-4233-abf6-3b2ac50e28d9",
94 reset_gpio ? reset_supported : reset_unsupported,
95 reset_gpio ? ARRAY_SIZE(reset_supported) : ARRAY_SIZE(reset_unsupported),
96 NULL),
99 acpigen_write_dsm_uuid_arr(uuid_callbacks, ARRAY_SIZE(uuid_callbacks));
101 * PowerResource (BTRT, 0, 0)
103 * Method (_STA, 0, NotSerialized)
105 * Return (\_SB.PCI0.GBTE())
107 * Method (_ON, 0, NotSerialized)
109 * \_SB.PCI0.SBTE(1)
111 * Method (_OFF, 0, NotSerialized)
113 * \_SB.PCI0.SBTE(0)
115 * Method (_RST, 0, NotSerialized)
117 * Local0 = Acquire (\_SB.PCI0.CNMT, 1000)
118 * If ((Local0 == Zero))
120 * \_SB.PCI0.BTRK (Zero)
121 * Sleep (RDLY)
122 * \_SB.PCI0.BTRK (One)
123 * Sleep (RDLY)
124 * Release (\_SB.PCI0.CNMT)
129 acpigen_write_power_res("BTRT", 0, 0, NULL, 0);
131 acpigen_write_method("_STA", 0);
133 if (enable_gpio) {
134 acpigen_write_store();
135 acpigen_emit_namestring("\\_SB.PCI0.GBTE");
136 acpigen_emit_byte(LOCAL0_OP);
138 acpigen_write_return_op(LOCAL0_OP);
139 } else {
140 acpigen_write_return_integer(1);
143 acpigen_pop_len();
145 acpigen_write_method("_ON", 0);
147 if (enable_gpio) {
148 acpigen_emit_namestring("\\_SB.PCI0.SBTE");
149 acpigen_emit_byte(1);
152 acpigen_pop_len();
154 acpigen_write_method("_OFF", 0);
156 if (enable_gpio) {
157 acpigen_emit_namestring("\\_SB.PCI0.SBTE");
158 acpigen_emit_byte(0);
161 acpigen_pop_len();
163 acpigen_write_method("_RST", 0);
165 if (reset_gpio) {
166 acpigen_write_store();
167 acpigen_write_acquire("\\_SB.PCI0.CNMT", 1000);
168 acpigen_emit_byte(LOCAL0_OP);
170 acpigen_write_if_lequal_op_int(LOCAL0_OP, 0);
172 acpigen_emit_namestring("\\_SB.PCI0.BTRK");
173 acpigen_emit_byte(0);
175 acpigen_emit_ext_op(SLEEP_OP);
176 acpigen_emit_namestring("RDLY");
178 acpigen_emit_namestring("\\_SB.PCI0.BTRK");
179 acpigen_emit_byte(1);
181 acpigen_emit_ext_op(SLEEP_OP);
182 acpigen_emit_namestring("RDLY");
184 acpigen_write_release("\\_SB.PCI0.CNMT");
186 acpigen_pop_len();
189 acpigen_pop_len();
191 acpigen_write_power_res_end();
194 * Name (_PRR, Package (0x01)
196 * BTRT
197 * })
199 acpigen_write_name("_PRR");
201 acpigen_write_package(1);
202 acpigen_emit_namestring("BTRT");
204 acpigen_pop_len();
207 * Name (_PR0, Package (0x01)
209 * BTRT
210 * })
212 acpigen_write_name("_PR0");
214 acpigen_write_package(1);
215 acpigen_emit_namestring("BTRT");
217 acpigen_pop_len();
220 * Name (_PR3, Package (0x01)
222 * BTRT
223 * })
225 acpigen_write_name("_PR3");
227 acpigen_write_package(1);
228 acpigen_emit_namestring("BTRT");
230 acpigen_pop_len();
233 * Method (AOLD, 0, Serialized)
235 * Name (AODS, Package (0x03)
237 * Zero,
238 * 0x12,
239 * Zero // Audio Offload - 0: Disabled
240 * 1: Enabled
241 * })
242 * Return (AODS)
245 acpigen_write_method_serialized("AOLD", 0);
247 acpigen_write_name("AODS");
248 acpigen_write_package(3);
250 acpigen_write_integer(0);
251 acpigen_write_integer(0x12);
252 acpigen_write_integer(audio_offload);
254 acpigen_pop_len();
256 acpigen_write_return_namestr("AODS");
258 acpigen_pop_len();
261 void acpi_device_intel_bt_common(unsigned int enable_gpio, unsigned int reset_gpio)
263 acpigen_write_scope("\\_SB.PCI0");
265 * Mutex (CNMT, 0)
267 acpigen_write_mutex("CNMT", 0);
270 * Method (SBTE, 1, Serialized)
272 * If (Arg0 == 1)
274 * STXS(enable_gpio)
275 * } Else {
276 * CTXS(enable_gpio)
280 acpigen_write_method_serialized("SBTE", 1);
282 if (enable_gpio) {
283 acpigen_write_if_lequal_op_int(ARG0_OP, 1);
285 acpigen_soc_set_tx_gpio(enable_gpio);
287 acpigen_write_else();
289 acpigen_soc_clear_tx_gpio(enable_gpio);
291 acpigen_pop_len();
294 acpigen_pop_len();
297 * Method (GBTE, 0, NotSerialized)
299 * Return (GTXS (enable_gpio))
302 acpigen_write_method("GBTE", 0);
304 if (enable_gpio) {
305 acpigen_soc_get_tx_gpio(enable_gpio);
306 acpigen_write_return_op(LOCAL0_OP);
307 } else {
308 acpigen_write_return_integer(0);
311 acpigen_pop_len();
314 * Method (BTRK, 1, Serialized)
316 * If (Arg0 == 1)
318 * STXS (reset_gpio)
319 * } Else {
320 * CTXS (reset_gpio)
324 acpigen_write_method_serialized("BTRK", 1);
326 acpigen_write_if_lequal_op_int(ARG0_OP, 1);
328 acpigen_soc_set_tx_gpio(reset_gpio);
330 acpigen_write_else();
332 acpigen_soc_clear_tx_gpio(reset_gpio);
334 acpigen_pop_len();
336 acpigen_pop_len();
339 * Method (GBTR, 0, NotSerialized)
341 * Return (GTXS (reset_gpio))
344 acpigen_write_method("GBTR", 0);
346 if (reset_gpio) {
347 acpigen_soc_get_tx_gpio(reset_gpio);
348 acpigen_write_return_op(LOCAL0_OP);
349 } else {
350 acpigen_write_return_op(0);
353 acpigen_pop_len();
355 acpigen_pop_len();