| 1 |
|
| 2 |
|
| 3 |
#include <acpi/acpigen.h> |
| 4 |
#include <option.h> |
| 5 |
#include "chip.h" |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
static void check_reset_delay(void *arg) |
| 23 |
{ |
| 24 |
acpigen_write_if_lequal_op_int(ARG1_OP, 0); |
| 25 |
{ |
| 26 |
acpigen_write_return_singleton_buffer(0x03); |
| 27 |
} |
| 28 |
acpigen_write_else(); |
| 29 |
{ |
| 30 |
acpigen_write_return_singleton_buffer(0x00); |
| 31 |
} |
| 32 |
acpigen_pop_len(); |
| 33 |
} |
| 34 |
|
| 35 |
static void set_reset_delay(void *arg) |
| 36 |
{ |
| 37 |
acpigen_write_store_op_to_namestr(ARG3_OP, "RDLY"); |
| 38 |
} |
| 39 |
|
| 40 |
static void not_supported(void *arg) |
| 41 |
{ |
| 42 |
acpigen_write_return_singleton_buffer(0x00); |
| 43 |
} |
| 44 |
|
| 45 |
void (*reset_supported[])(void *) = { check_reset_delay, set_reset_delay }; |
| 46 |
void (*reset_unsupported[])(void *) = { not_supported }; |
| 47 |
|
| 48 |
void acpi_device_intel_bt(const struct acpi_gpio *enable_gpio, |
| 49 |
const struct acpi_gpio *reset_gpio, |
| 50 |
bool audio_offload) |
| 51 |
{ |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
if (get_uint_option("bluetooth_rtd3", 1)) |
| 56 |
acpigen_write_name_integer("_S0W", ACPI_DEVICE_SLEEP_D3_HOT); |
| 57 |
else |
| 58 |
acpigen_write_name_integer("_S0W", ACPI_DEVICE_SLEEP_D0); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
acpi_device_add_hotplug_support_in_d3(NULL); |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
acpigen_write_name_integer("RDLY", 0x69); |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
struct dsm_uuid uuid_callbacks[] = { |
| 121 |
DSM_UUID("aa10f4e0-81ac-4233-abf6-3b2ac50e28d9", |
| 122 |
reset_gpio->pin_count ? |
| 123 |
reset_supported : reset_unsupported, |
| 124 |
reset_gpio->pin_count ? |
| 125 |
ARRAY_SIZE(reset_supported) : ARRAY_SIZE(reset_unsupported), |
| 126 |
NULL), |
| 127 |
}; |
| 128 |
|
| 129 |
acpigen_write_dsm_uuid_arr(uuid_callbacks, ARRAY_SIZE(uuid_callbacks)); |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
acpigen_write_power_res("BTRT", 0, 0, NULL, 0); |
| 163 |
{ |
| 164 |
acpigen_write_method("_STA", 0); |
| 165 |
{ |
| 166 |
if (enable_gpio->pin_count) { |
| 167 |
acpigen_write_store(); |
| 168 |
acpigen_emit_namestring("\\_SB.PCI0.GBTE"); |
| 169 |
acpigen_emit_byte(LOCAL0_OP); |
| 170 |
|
| 171 |
acpigen_write_return_op(LOCAL0_OP); |
| 172 |
} else { |
| 173 |
acpigen_write_return_integer(1); |
| 174 |
} |
| 175 |
} |
| 176 |
acpigen_pop_len(); |
| 177 |
|
| 178 |
acpigen_write_method("_ON", 0); |
| 179 |
{ |
| 180 |
if (get_uint_option("bluetooth_rtd3", 1) && enable_gpio->pin_count) { |
| 181 |
acpigen_write_store(); |
| 182 |
acpigen_emit_namestring("\\_SB.PCI0.GBTE"); |
| 183 |
acpigen_emit_byte(LOCAL0_OP); |
| 184 |
|
| 185 |
acpigen_write_if_lequal_op_int(LOCAL0_OP, 1); |
| 186 |
{ |
| 187 |
acpigen_write_return_integer(1); |
| 188 |
} |
| 189 |
acpigen_pop_len(); |
| 190 |
|
| 191 |
acpigen_emit_namestring("\\_SB.PCI0.SBTE"); |
| 192 |
acpigen_emit_byte(1); |
| 193 |
} |
| 194 |
} |
| 195 |
acpigen_pop_len(); |
| 196 |
|
| 197 |
acpigen_write_method("_OFF", 0); |
| 198 |
{ |
| 199 |
if (get_uint_option("bluetooth_rtd3", 1) && enable_gpio->pin_count) { |
| 200 |
acpigen_emit_namestring("\\_SB.PCI0.SBTE"); |
| 201 |
acpigen_emit_byte(0); |
| 202 |
} |
| 203 |
} |
| 204 |
acpigen_pop_len(); |
| 205 |
|
| 206 |
acpigen_write_method("_RST", 0); |
| 207 |
{ |
| 208 |
if (reset_gpio->pin_count) { |
| 209 |
acpigen_write_store(); |
| 210 |
acpigen_write_acquire("\\_SB.PCI0.CNMT", 1000); |
| 211 |
acpigen_emit_byte(LOCAL0_OP); |
| 212 |
|
| 213 |
acpigen_write_if_lequal_op_int(LOCAL0_OP, 0); |
| 214 |
{ |
| 215 |
acpigen_emit_namestring("\\_SB.PCI0.BTRK"); |
| 216 |
acpigen_emit_byte(0); |
| 217 |
|
| 218 |
acpigen_emit_ext_op(SLEEP_OP); |
| 219 |
acpigen_emit_namestring("RDLY"); |
| 220 |
|
| 221 |
acpigen_emit_namestring("\\_SB.PCI0.BTRK"); |
| 222 |
acpigen_emit_byte(1); |
| 223 |
|
| 224 |
acpigen_emit_ext_op(SLEEP_OP); |
| 225 |
acpigen_emit_namestring("RDLY"); |
| 226 |
|
| 227 |
acpigen_write_release("\\_SB.PCI0.CNMT"); |
| 228 |
} |
| 229 |
acpigen_pop_len(); |
| 230 |
} |
| 231 |
} |
| 232 |
acpigen_pop_len(); |
| 233 |
} |
| 234 |
acpigen_write_power_res_end(); |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
acpigen_write_name("_PRR"); |
| 243 |
{ |
| 244 |
acpigen_write_package(1); |
| 245 |
acpigen_emit_namestring("BTRT"); |
| 246 |
} |
| 247 |
acpigen_pop_len(); |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
acpigen_write_name("_PR0"); |
| 256 |
{ |
| 257 |
acpigen_write_package(1); |
| 258 |
acpigen_emit_namestring("BTRT"); |
| 259 |
} |
| 260 |
acpigen_pop_len(); |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
acpigen_write_method("AOLD", 0); |
| 276 |
{ |
| 277 |
acpigen_write_name("AODS"); |
| 278 |
acpigen_write_package(3); |
| 279 |
{ |
| 280 |
acpigen_write_integer(0); |
| 281 |
acpigen_write_integer(0x12); |
| 282 |
acpigen_write_integer(audio_offload); |
| 283 |
} |
| 284 |
acpigen_pop_len(); |
| 285 |
|
| 286 |
acpigen_write_return_namestr("AODS"); |
| 287 |
} |
| 288 |
acpigen_pop_len(); |
| 289 |
} |
| 290 |
|
| 291 |
void acpi_device_intel_bt_common(const struct acpi_gpio *enable_gpio, |
| 292 |
const struct acpi_gpio *reset_gpio) |
| 293 |
{ |
| 294 |
acpigen_write_scope("\\_SB.PCI0"); |
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
acpigen_write_mutex("CNMT", 0); |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
acpigen_write_method("SBTE", 1); |
| 312 |
{ |
| 313 |
if (enable_gpio->pin_count) { |
| 314 |
acpigen_write_if_lequal_op_int(ARG0_OP, 1); |
| 315 |
{ |
| 316 |
acpigen_enable_tx_gpio(enable_gpio); |
| 317 |
} |
| 318 |
acpigen_write_else(); |
| 319 |
{ |
| 320 |
acpigen_disable_tx_gpio(enable_gpio); |
| 321 |
} |
| 322 |
acpigen_pop_len(); |
| 323 |
} |
| 324 |
} |
| 325 |
acpigen_pop_len(); |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
acpigen_write_method("GBTE", 0); |
| 334 |
{ |
| 335 |
if (enable_gpio->pin_count) { |
| 336 |
acpigen_get_tx_gpio(enable_gpio); |
| 337 |
acpigen_write_return_op(LOCAL0_OP); |
| 338 |
} else { |
| 339 |
acpigen_write_return_integer(0); |
| 340 |
} |
| 341 |
} |
| 342 |
acpigen_pop_len(); |
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
acpigen_write_method("BTRK", 1); |
| 356 |
{ |
| 357 |
if (reset_gpio->pin_count) { |
| 358 |
acpigen_write_if_lequal_op_int(ARG0_OP, 1); |
| 359 |
{ |
| 360 |
|
| 361 |
acpigen_disable_tx_gpio(reset_gpio); |
| 362 |
} |
| 363 |
acpigen_write_else(); |
| 364 |
{ |
| 365 |
|
| 366 |
acpigen_enable_tx_gpio(reset_gpio); |
| 367 |
} |
| 368 |
acpigen_pop_len(); |
| 369 |
} |
| 370 |
} |
| 371 |
acpigen_pop_len(); |
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
acpigen_write_method("GBTR", 0); |
| 382 |
{ |
| 383 |
if (reset_gpio->pin_count) { |
| 384 |
|
| 385 |
acpigen_get_tx_gpio(reset_gpio); |
| 386 |
acpigen_write_xor(LOCAL0_OP, 1, LOCAL0_OP); |
| 387 |
acpigen_write_return_op(LOCAL0_OP); |
| 388 |
} else { |
| 389 |
acpigen_write_return_op(0); |
| 390 |
} |
| 391 |
} |
| 392 |
acpigen_pop_len(); |
| 393 |
|
| 394 |
acpigen_write_scope_end(); |
| 395 |
} |