Debian Codegraph @

src/soc/intel/common/block/cnvi/cnvi.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <acpi/acpi.h>
4 #include <acpi/acpi_device.h>
5 #include <acpi/acpigen.h>
6 #include <device/device.h>
7 #include <device/pci.h>
8 #include <device/pci_ids.h>
9 #include <intelblocks/cnvi.h>
10 #include <soc/cnvi.h>
11 #include <soc/pcr_ids.h>
12
13 #include "chip.h"
14
15 static const char *cnvi_wifi_acpi_name(const struct device *dev)
16 {
17 return "CNVW";
18 }
19
20 static void cnvw_fill_ssdt(const struct device *dev)
21 {
22 const char *scope = acpi_device_path(dev);
23
24 acpi_device_write_pci_dev(dev);
25
26 acpigen_write_scope(scope);
27 /*
28 * OperationRegion(CWAR, SystemMemory, \_SB_.PCI0.BASE(_ADR), 0x100)
29 * Field(CWAR, WordAcc, NoLock, Preserve) {
30 * VDID, 32, // 0x00, VID DID
31 * Offset(CNVI_DEV_CAP),
32 * , 28,
33 * WFLR, 1, // Function Level Reset Capable
34 * Offset(CNVI_DEV_CONTROL),
35 * , 15,
36 * WIFR, 1, // Init Function Level Reset
37 * Offset(CNVI_POWER_STATUS),
38 * WPMS, 32,
39 * }
40 */
41
42 /* RegionOffset stored in Local0 */
43 /* Local0 = \_SB_.PCI0.BASE(_ADR) */
44 acpigen_write_store();
45 acpigen_emit_namestring("\\_SB_.PCI0.BASE");
46 acpigen_emit_namestring("_ADR");
47 acpigen_emit_byte(LOCAL0_OP);
48
49 /* OperationRegion */
50 acpigen_emit_ext_op(OPREGION_OP);
51 /* NameString 4 chars only */
52 acpigen_emit_namestring("CWAR");
53 /* RegionSpace */
54 acpigen_emit_byte(SYSTEMMEMORY);
55 /* RegionOffset */
56 acpigen_emit_byte(LOCAL0_OP);
57 /* RegionLen */
58 acpigen_write_integer(0x100);
59
60 struct fieldlist fields[] = {
61 FIELDLIST_OFFSET(0),
62 FIELDLIST_NAMESTR("VDID", 32),
63 FIELDLIST_OFFSET(CNVI_DEV_CAP),
64 FIELDLIST_RESERVED(28),
65 FIELDLIST_NAMESTR("WFLR", 1),
66 FIELDLIST_OFFSET(CNVI_DEV_CONTROL),
67 FIELDLIST_RESERVED(15),
68 FIELDLIST_NAMESTR("WIFR", 1),
69 FIELDLIST_OFFSET(CNVI_POWER_STATUS),
70 FIELDLIST_NAMESTR("WPMS", 32),
71 };
72 acpigen_write_field("CWAR", fields, ARRAY_SIZE(fields),
73 FIELD_WORDACC | FIELD_NOLOCK | FIELD_PRESERVE);
74
75 /*
76 * Field (CWAR, ByteAcc, NoLock, Preserve)
77 * {
78 * Offset (0xcd),
79 * PMEE, 1,
80 * , 6,
81 * PMES, 1
82 * }
83 */
84 struct fieldlist fields2[] = {
85 FIELDLIST_OFFSET(0xcd),
86 FIELDLIST_NAMESTR("PMEE", 1),
87 FIELDLIST_RESERVED(6),
88 FIELDLIST_NAMESTR("PMES", 1),
89 };
90 acpigen_write_field("CWAR", fields2, ARRAY_SIZE(fields2),
91 FIELD_BYTEACC | FIELD_NOLOCK | FIELD_PRESERVE);
92
93 /*
94 * Name (_S0W, 3)
95 */
96 acpigen_write_name_integer("_S0W", ACPI_DEVICE_SLEEP_D3_HOT);
97
98 /*
99 * Name (PRRS, Zero)
100 * Last _PRR Status
101 * 0: Non-Platform-Level Device Reset (PLDR) executed [Default]
102 * 1: Core PLDR Completed successfully
103 * 2: Product PLDR Completed successfully
104 * 3: Previous PLDR Not Completed
105 * 4: Product PLDR timeout
106 */
107 acpigen_write_name_integer("PRRS", 0);
108
109 /*
110 * Name (RSTT, Zero)
111 * Reset Type
112 * 0: Core Reset
113 * 1: Product Reset
114 */
115 acpigen_write_name_integer("RSTT", 0);
116
117 /*
118 * Wi-Fi PLDR request delay (default 50 ms)
119 */
120 acpigen_write_name_integer("WFDL", 50);
121
122 /*
123 * PowerResource (CNVP, 0x00, 0x0000)
124 * {
125 * Method (_STA, 0, NotSerialized) // _STA: Status
126 * {
127 * If (CondRefOf (\_SB.PCI0.CNVS))
128 * {
129 * Local0 = \_SB.PCI0.CNVS()
130 * Return (Local0)
131 * }
132 * Else
133 * {
134 * Return (One)
135 * }
136 * }
137 *
138 * Method (_ON, 0, NotSerialized) // _ON_: Power On
139 * {
140 * If (CondRefOf (\_SB.PCI0.CNVC))
141 * {
142 * Local0 = \_SB.PCI0.CNVS()
143 * If ((Local0 == One))
144 * {
145 * Return (One)
146 * }
147 *
148 * \_SB.PCI0.CNVC (One)
149 * }
150 * }
151 *
152 * Method (_OFF, 0, NotSerialized) // _OFF: Power Off
153 * {
154 * If (CondRefOf (\_SB.PCI0.CNVC))
155 * {
156 * \_SB.PCI0.CNVC (Zero)
157 * }
158 * }
159 *
160 * Method (_RST, 0, NotSerialized) // _RST: Device Reset
161 * {
162 * Local0 = Acquire (\_SB.PCI0.CNMT, 0x03E8)
163 * If ((Local0 == Zero))
164 * {
165 * CFLR ()
166 * PRRS = One
167 * If ((RSTT == One))
168 * {
169 * Local0 = \_SB.PCI0.PCRR(PID_CNVI, CNVI_ABORT_PLDR)
170 * Local0 &= CNVI_ABORT_REQUEST
171 * If ((Local0 == Zero))
172 * {
173 * Local2 = Zero
174 * If (CondRefOf (\_SB.PCI0.GBTR))
175 * {
176 * If ((\_SB.PCI0.GBTR == One))
177 * {
178 * \_SB.PCI0.BTRK (Zero)
179 * Sleep (0xA0)
180 * Local2 = One
181 * }
182 * }
183 *
184 * If (CondRefOf (\_SB.PCI0.CNVB))
185 * {
186 * \_SB.PCI0.CNVB.CFLR ()
187 * }
188 *
189 * \_SB.PCI0.PCRO (PID_CNVI, CNVI_ABORT_PLDR, 0x03)
190 * Sleep (WFDL)
191 * Local0 = \_SB.PCI0.PCRR(PID_CNVI, CNVI_ABORT_PLDR)
192 * Local1 = (Local0 & CNVI_ABORT_REQUEST)
193 * Local3 = (Local0 & CNVI_READY)
194 * If ((Local1 == Zero))
195 * {
196 * If ((Local3 == CNVI_READY))
197 * {
198 * PRRS = CNVI_PLDR_COMPLETE
199 * If ((Local2 == One))
200 * {
201 * \_SB.PCI0.BTRK (One)
202 * Sleep (0xA0)
203 * }
204 * }
205 * }
206 * Else
207 * {
208 * PRRS = CNVI_PLDR_NOT_COMPLETE
209 * }
210 * }
211 * Else
212 * {
213 * PRRS = CNVI_PLDR_TIMEOUT
214 * }
215 * }
216 * Release (\_SB.PCI0.CNMT)
217 * }
218 * }
219 * }
220 *
221 */
222 acpigen_write_power_res("CNVP", 0, 0, NULL, 0);
223 {
224 acpigen_write_method("_STA", 0);
225 {
226 acpigen_write_if_cond_ref_of("\\_SB.PCI0.CNVS");
227 {
228 acpigen_write_store();
229 acpigen_emit_namestring("\\_SB.PCI0.CNVS");
230 acpigen_emit_byte(LOCAL0_OP);
231
232 acpigen_write_return_op(LOCAL0_OP);
233 }
234 acpigen_write_else();
235 {
236 acpigen_write_return_integer(1);
237 }
238 acpigen_pop_len();
239 }
240 acpigen_pop_len();
241
242 acpigen_write_method("_ON", 0);
243 {
244 acpigen_write_if_cond_ref_of("\\_SB.PCI0.CNVC");
245 {
246
247 acpigen_write_store();
248 acpigen_emit_namestring("\\_SB.PCI0.CNVS");
249 acpigen_emit_byte(LOCAL0_OP);
250
251 acpigen_write_if_lequal_op_int(LOCAL0_OP, 1);
252 {
253 acpigen_write_return_integer(1);
254 }
255 acpigen_pop_len();
256
257 acpigen_emit_namestring("\\_SB.PCI0.CNVC");
258 acpigen_emit_byte(1);
259 }
260 acpigen_pop_len();
261 }
262 acpigen_pop_len();
263
264 acpigen_write_method("_OFF", 0);
265 {
266 acpigen_write_if_cond_ref_of("\\_SB.PCI0.CNVC");
267 {
268 acpigen_emit_namestring("\\_SB.PCI0.CNVC");
269 acpigen_emit_byte(0);
270 }
271 acpigen_pop_len();
272 }
273 acpigen_pop_len();
274
275 acpigen_write_method("_RST", 0);
276 {
277 acpigen_write_store();
278 acpigen_write_acquire("\\_SB.PCI0.CNMT", 1000);
279 acpigen_emit_byte(LOCAL0_OP);
280
281 acpigen_write_if_lequal_op_int(LOCAL0_OP, 0);
282 {
283 acpigen_emit_namestring("CFLR");
284
285 acpigen_write_store_int_to_namestr(1, "PRRS");
286
287 acpigen_write_if_lequal_namestr_int("RSTT", 1);
288 {
289 acpigen_write_store();
290 acpigen_emit_namestring("\\_SB.PCI0.PCRR");
291 acpigen_write_integer(PID_CNVI);
292 acpigen_write_integer(CNVI_ABORT_PLDR);
293 acpigen_emit_byte(LOCAL0_OP);
294
295 acpigen_emit_byte(AND_OP);
296 acpigen_emit_byte(LOCAL0_OP);
297 acpigen_write_integer(CNVI_ABORT_REQUEST);
298 acpigen_emit_byte(LOCAL0_OP);
299
300 acpigen_write_if_lequal_op_int(LOCAL0_OP, 0);
301 {
302 acpigen_write_store_int_to_op(0, LOCAL2_OP);
303 acpigen_write_if_cond_ref_of("\\_SB.PCI0.GBTR");
304 {
305 acpigen_write_if_lequal_namestr_int("\\_SB.PCI0.GBTR", 1);
306 {
307 acpigen_emit_namestring("\\_SB.PCI0.BTRK");
308 acpigen_emit_byte(0);
309
310 acpigen_write_sleep(160);
311
312 acpigen_write_store_ops(1, LOCAL2_OP);
313 }
314 acpigen_pop_len();
315 }
316 acpigen_pop_len();
317
318 acpigen_write_if_cond_ref_of("\\_SB.PCI0.CNVB");
319 {
320 acpigen_emit_namestring("\\_SB.PCI0.CNVB.CFLR");
321 }
322 acpigen_pop_len();
323
324 acpigen_emit_namestring("\\_SB.PCI0.PCRO");
325 acpigen_write_integer(PID_CNVI);
326 acpigen_write_integer(CNVI_ABORT_PLDR);
327 acpigen_write_integer(CNVI_ABORT_REQUEST | CNVI_ABORT_ENABLE);
328
329 acpigen_emit_ext_op(SLEEP_OP);
330 acpigen_emit_namestring("WFDL");
331
332 acpigen_write_store();
333 acpigen_emit_namestring("\\_SB.PCI0.PCRR");
334 acpigen_write_integer(PID_CNVI);
335 acpigen_write_integer(CNVI_ABORT_PLDR);
336 acpigen_emit_byte(LOCAL0_OP);
337
338 acpigen_emit_byte(AND_OP);
339 acpigen_emit_byte(LOCAL0_OP);
340 acpigen_write_integer(CNVI_ABORT_REQUEST);
341 acpigen_emit_byte(LOCAL1_OP);
342
343 acpigen_emit_byte(AND_OP);
344 acpigen_emit_byte(LOCAL0_OP);
345 acpigen_write_integer(CNVI_READY);
346 acpigen_emit_byte(LOCAL3_OP);
347
348 acpigen_write_if_lequal_op_int(LOCAL1_OP, 0);
349 {
350 acpigen_write_if_lequal_op_int(LOCAL3_OP, CNVI_READY);
351 {
352 acpigen_write_store_int_to_namestr(CNVI_PLDR_COMPLETE, "PRRS");
353
354 acpigen_write_if_lequal_op_int(LOCAL2_OP, 1);
355 {
356 acpigen_emit_namestring("\\_SB.PCI0.BTRK");
357 acpigen_emit_byte(1);
358 acpigen_write_sleep(160);
359 }
360 acpigen_pop_len();
361 }
362 acpigen_pop_len();
363 }
364 acpigen_write_else();
365 {
366 acpigen_write_store_int_to_namestr(CNVI_PLDR_NOT_COMPLETE, "PRRS");
367 }
368 acpigen_pop_len();
369 }
370 acpigen_write_else();
371 {
372 acpigen_write_store_int_to_namestr(CNVI_PLDR_TIMEOUT, "PRRS");
373 }
374 acpigen_pop_len();
375 }
376 acpigen_pop_len();
377 acpigen_write_release("\\_SB.PCI0.CNMT");
378 }
379 acpigen_pop_len();
380 }
381 acpigen_pop_len();
382 }
383 acpigen_write_power_res_end();
384
385 /*
386 * Name (_PRR, Package (0x01)
387 * {
388 * CNVP
389 * })
390 */
391 acpigen_write_name("_PRR");
392 {
393 acpigen_write_package(1);
394 acpigen_emit_namestring("CNVP");
395 }
396 acpigen_pop_len();
397
398 /*
399 * Name (_PR0, Package (0x01)
400 * {
401 * CNVP
402 * })
403 */
404 acpigen_write_name("_PR0");
405 {
406 acpigen_write_package(1);
407 acpigen_emit_namestring("CNVP");
408 }
409 acpigen_pop_len();
410
411 /*
412 * Method (GPEH, 0, NotSerialized)
413 * {
414 * If ((VDID == 0xFFFFFFFF))
415 * {
416 * Return (Zero)
417 * }
418 * If ((PMES == One))
419 * {
420 * Notify (CNVW, 0x02) // Device Wake
421 * }
422 * }
423 */
424 acpigen_write_method("GPEH", 0);
425 {
426 acpigen_write_if_lequal_namestr_int("VDID", 0xffffffff);
427 {
428 acpigen_write_return_integer(0);
429 }
430 acpigen_pop_len();
431
432 acpigen_write_if_lequal_namestr_int("PMES", 1);
433 {
434 acpigen_notify("CNVW", 2);
435 }
436 acpigen_pop_len();
437 }
438 acpigen_pop_len();
439
440 /*
441 * Method (CFLR, 0, NotSerialized)
442 * {
443 * If (WFLR == One)
444 * {
445 * WIFR = One
446 * }
447 * }
448 */
449 acpigen_write_method("CFLR", 0);
450 {
451 acpigen_write_if_lequal_namestr_int("WFLR", 1);
452 {
453 acpigen_write_store_int_to_namestr(1, "WIFR");
454 }
455 acpigen_pop_len();
456 }
457 acpigen_pop_len();
458
459 acpigen_write_scope_end();
460 }
461
462 static struct device_operations cnvi_wifi_ops = {
463 .read_resources = pci_dev_read_resources,
464 .set_resources = pci_dev_set_resources,
465 .enable_resources = pci_dev_enable_resources,
466 .ops_pci = &pci_dev_ops_pci,
467 .scan_bus = scan_static_bus,
468 .acpi_name = cnvi_wifi_acpi_name,
469 .acpi_fill_ssdt = cnvw_fill_ssdt,
470 };
471
472 static const unsigned short wifi_pci_device_ids[] = {
473 PCI_DID_INTEL_WCL_CNVI_WIFI_0,
474 PCI_DID_INTEL_WCL_CNVI_WIFI_1,
475 PCI_DID_INTEL_WCL_CNVI_WIFI_2,
476 PCI_DID_INTEL_WCL_CNVI_WIFI_3,
477 PCI_DID_INTEL_PTL_H_CNVI_WIFI_0,
478 PCI_DID_INTEL_PTL_H_CNVI_WIFI_1,
479 PCI_DID_INTEL_PTL_H_CNVI_WIFI_2,
480 PCI_DID_INTEL_PTL_H_CNVI_WIFI_3,
481 PCI_DID_INTEL_PTL_U_H_CNVI_WIFI_0,
482 PCI_DID_INTEL_PTL_U_H_CNVI_WIFI_1,
483 PCI_DID_INTEL_PTL_U_H_CNVI_WIFI_2,
484 PCI_DID_INTEL_PTL_U_H_CNVI_WIFI_3,
485 PCI_DID_INTEL_LNL_CNVI_WIFI_0,
486 PCI_DID_INTEL_LNL_CNVI_WIFI_1,
487 PCI_DID_INTEL_LNL_CNVI_WIFI_2,
488 PCI_DID_INTEL_LNL_CNVI_WIFI_3,
489 PCI_DID_INTEL_MTL_CNVI_WIFI_0,
490 PCI_DID_INTEL_MTL_CNVI_WIFI_1,
491 PCI_DID_INTEL_MTL_CNVI_WIFI_2,
492 PCI_DID_INTEL_MTL_CNVI_WIFI_3,
493 PCI_DID_INTEL_ARL_CNVI_WIFI,
494 PCI_DID_INTEL_ARP_S_CNVI_WIFI,
495 PCI_DID_INTEL_CML_LP_CNVI_WIFI,
496 PCI_DID_INTEL_CML_H_CNVI_WIFI,
497 PCI_DID_INTEL_CNL_LP_CNVI_WIFI,
498 PCI_DID_INTEL_CNL_H_CNVI_WIFI,
499 PCI_DID_INTEL_GLK_CNVI_WIFI,
500 PCI_DID_INTEL_JSL_CNVI_WIFI_0,
501 PCI_DID_INTEL_JSL_CNVI_WIFI_1,
502 PCI_DID_INTEL_JSL_CNVI_WIFI_2,
503 PCI_DID_INTEL_JSL_CNVI_WIFI_3,
504 PCI_DID_INTEL_TGL_CNVI_WIFI_0,
505 PCI_DID_INTEL_TGL_CNVI_WIFI_1,
506 PCI_DID_INTEL_TGL_CNVI_WIFI_2,
507 PCI_DID_INTEL_TGL_CNVI_WIFI_3,
508 PCI_DID_INTEL_TGL_H_CNVI_WIFI_0,
509 PCI_DID_INTEL_TGL_H_CNVI_WIFI_1,
510 PCI_DID_INTEL_TGL_H_CNVI_WIFI_2,
511 PCI_DID_INTEL_TGL_H_CNVI_WIFI_3,
512 PCI_DID_INTEL_ADL_P_CNVI_WIFI_0,
513 PCI_DID_INTEL_ADL_P_CNVI_WIFI_1,
514 PCI_DID_INTEL_ADL_P_CNVI_WIFI_2,
515 PCI_DID_INTEL_ADL_P_CNVI_WIFI_3,
516 PCI_DID_INTEL_ADL_S_CNVI_WIFI_0,
517 PCI_DID_INTEL_ADL_S_CNVI_WIFI_1,
518 PCI_DID_INTEL_ADL_S_CNVI_WIFI_2,
519 PCI_DID_INTEL_ADL_S_CNVI_WIFI_3,
520 PCI_DID_INTEL_ADL_N_CNVI_WIFI_0,
521 PCI_DID_INTEL_ADL_N_CNVI_WIFI_1,
522 PCI_DID_INTEL_ADL_N_CNVI_WIFI_2,
523 PCI_DID_INTEL_ADL_N_CNVI_WIFI_3,
524 PCI_DID_INTEL_RPL_S_CNVI_WIFI_0,
525 PCI_DID_INTEL_RPL_S_CNVI_WIFI_1,
526 PCI_DID_INTEL_RPL_S_CNVI_WIFI_2,
527 PCI_DID_INTEL_RPL_S_CNVI_WIFI_3,
528 0
529 };
530
531 static const struct pci_driver pch_cnvi_wifi __pci_driver = {
532 .ops = &cnvi_wifi_ops,
533 .vendor = PCI_VID_INTEL,
534 .devices = wifi_pci_device_ids,
535 };
536
537 static const char *cnvi_bt_acpi_name(const struct device *dev)
538 {
539 return "CNVB";
540 }
541
542 static void cnvb_fill_ssdt(const struct device *dev)
543 {
544 const char *scope = acpi_device_path(dev);
545
546 /*
547 * Mutex (CNMT, 0)
548 */
549 acpigen_write_scope("\\_SB.PCI0");
550 acpigen_write_mutex("CNMT", 0);
551 acpigen_write_scope_end();
552
553 acpi_device_write_pci_dev(dev);
554
555 acpigen_write_scope(scope);
556
557 /*
558 * OperationRegion (CBTR, SystemMemory, \_SB_.PCI0.BASE(_ADR), 0x100)
559 * Field (CBTR, WordAcc, NoLock, Preserve) {
560 * VDID, 32, // 0x00, VID DID
561 * Offset(R_CNVI_CFG_GIO_DEV_CAP),
562 * , 28,
563 * BFLR, 1, // Function Level Reset Capable
564 * Offset(R_CNVI_CFG_GIO_DEV),
565 * , 15,
566 * BIFR, 1, // Init Function Level Reset
567 * Offset (R_CNVI_CFG_GIO_DEV_CAP_2),
568 * , 11,
569 * BLTS, 1, // LTR Mechanism Supported
570 * Offset (R_CNVI_CFG_GIO_DEV_2),
571 * , 10,
572 * BLTE, 1, // LTR Mechanism Enable
573 * }
574 */
575
576 /* RegionOffset stored in Local0 */
577 /* Local0 = \_SB_.PCI0.BASE(_ADR) */
578 acpigen_write_store();
579 acpigen_emit_namestring("BASE");
580 acpigen_emit_namestring("_ADR");
581 acpigen_emit_byte(LOCAL0_OP);
582
583 acpigen_emit_ext_op(OPREGION_OP);
584 acpigen_emit_namestring("CBTR");
585 acpigen_emit_byte(SYSTEMMEMORY);
586 acpigen_emit_byte(LOCAL0_OP);
587 acpigen_write_integer(0x100);
588
589 struct fieldlist fields[] = {
590 FIELDLIST_OFFSET(0),
591 FIELDLIST_NAMESTR("VDID", 32),
592 FIELDLIST_OFFSET(CNVI_DEV_CAP),
593 FIELDLIST_RESERVED(28),
594 FIELDLIST_NAMESTR("BFLR", 1),
595 FIELDLIST_OFFSET(CNVI_DEV_CONTROL),
596 FIELDLIST_RESERVED(15),
597 FIELDLIST_NAMESTR("BIFR", 1),
598 FIELDLIST_OFFSET(CNVI_DEV_CAP_2),
599 FIELDLIST_RESERVED(11),
600 FIELDLIST_NAMESTR("BLTS", 1),
601 FIELDLIST_OFFSET(CNVI_DEV_CONTROL_2),
602 FIELDLIST_RESERVED(10),
603 FIELDLIST_NAMESTR("BLTE", 1),
604 };
605 acpigen_write_field("CBTR", fields, ARRAY_SIZE(fields),
606 FIELD_WORDACC | FIELD_NOLOCK | FIELD_PRESERVE);
607
608 /*
609 * Name (_S0W, 3)
610 */
611 acpigen_write_name_integer("_S0W", ACPI_DEVICE_SLEEP_D3_HOT);
612
613 /*
614 * Name (PRRS, Zero)
615 * Last _PRR Status
616 * 0: Non-Platform-Level Device Reset (PLDR) executed [Default]
617 * 1: Core PLDR Completed successfully
618 * 2: Product PLDR Completed successfully
619 * 3: Previous PLDR Not Completed
620 * 4: Product PLDR timeout
621 */
622 acpigen_write_name_integer("PRRS", 0);
623
624 /*
625 * Name (RSTT, Zero)
626 * Reset Type
627 * 0: Core Reset
628 * 1: Product Reset
629 */
630 acpigen_write_name_integer("RSTT", 0);
631
632 /*
633 * Bluetooth PLDR request delay (default 50 ms)
634 */
635 acpigen_write_name_integer("BTDL", 50);
636
637 /*
638 * PowerResource (CNVP, 0x05, 0x0000)
639 * {
640 * Method (_STA, 0, NotSerialized) // _STA: Status
641 * {
642 * Return (One)
643 * }
644 *
645 * Method (_ON, 0, NotSerialized) // _ON_: Power On
646 * {
647 * }
648 *
649 * Method (_OFF, 0, NotSerialized) // _OFF: Power Off
650 * {
651 * }
652 *
653 * Method (_RST, 0, NotSerialized) // _RST: Device Reset
654 * {
655 * Local0 = Acquire (\_SB.PCI0.CNMT, 0x03E8)
656 * If ((Local0 == Zero))
657 * {
658 * CFLR ()
659 * If ((RSTT == One))
660 * {
661 * Local0 = \_SB.PCI0.PCRR(PID_CNVI, CNVI_ABORT_PLDR)
662 * Local0 &= CNVI_ABORT_REQUEST
663 * If ((Local0 == Zero))
664 * {
665 * \_SB.PCI0.PCRO (PID_CNVI, CNVI_ABORT_PLDR, 0x03)
666 * Sleep (BTDL)
667 * Local0 = \_SB.PCI0.PCRR(PID_CNVI, CNVI_ABORT_PLDR)
668 * Local1 = (Local0 & CNVI_ABORT_REQUEST)
669 * Local3 = (Local0 & CNVI_READY)
670 * If ((Local1 == Zero))
671 * {
672 * If ((Local3 == CNVI_READY))
673 * {
674 * PRRS = CNVI_PLDR_COMPLETE
675 * }
676 * }
677 * Else
678 * {
679 * PRRS = CNVI_PLDR_TIMEOUT
680 * }
681 * }
682 * Else
683 * {
684 * PRRS = CNVI_PLDR_NOT_COMPLETE
685 * }
686 * }
687 *
688 * If ((BLTS == One))
689 * {
690 * If ((BLTE == Zero))
691 * {
692 * BLTE = One
693 * }
694 * }
695 *
696 * Release (\_SB.PCI0.CNMT)
697 * }
698 * }
699 * }
700 */
701 acpigen_write_power_res("CNVP", 5, 0, NULL, 0);
702 {
703 acpigen_write_method("_STA", 0);
704 {
705 acpigen_write_return_integer(1);
706 }
707 acpigen_pop_len();
708
709 acpigen_write_method("_ON", 0);
710 {
711 // Empty method body
712 }
713 acpigen_pop_len();
714
715 acpigen_write_method("_OFF", 0);
716 {
717 // Empty method body
718 }
719 acpigen_pop_len();
720
721 acpigen_write_method("_RST", 0);
722 {
723 acpigen_write_store();
724 acpigen_write_acquire("\\_SB.PCI0.CNMT", 1000);
725 acpigen_emit_byte(LOCAL0_OP);
726
727 acpigen_write_if_lequal_op_int(LOCAL0_OP, 0);
728 {
729 acpigen_emit_namestring("CFLR");
730
731 acpigen_write_if_lequal_namestr_int("RSTT", 1);
732 {
733 acpigen_write_store();
734 acpigen_emit_namestring("\\_SB.PCI0.PCRR");
735 acpigen_write_integer(PID_CNVI);
736 acpigen_write_integer(CNVI_ABORT_PLDR);
737 acpigen_emit_byte(LOCAL0_OP);
738
739 acpigen_emit_byte(AND_OP);
740 acpigen_emit_byte(LOCAL0_OP);
741 acpigen_write_integer(CNVI_ABORT_REQUEST);
742 acpigen_emit_byte(LOCAL0_OP);
743
744 acpigen_write_if_lequal_op_int(LOCAL0_OP, 0);
745 {
746 acpigen_emit_namestring("\\_SB.PCI0.PCRO");
747 acpigen_write_integer(PID_CNVI);
748 acpigen_write_integer(CNVI_ABORT_PLDR);
749 acpigen_write_integer(CNVI_ABORT_REQUEST | CNVI_ABORT_ENABLE);
750
751 acpigen_emit_ext_op(SLEEP_OP);
752 acpigen_emit_namestring("BTDL");
753
754 acpigen_write_store();
755 acpigen_emit_namestring("\\_SB.PCI0.PCRR");
756 acpigen_write_integer(PID_CNVI);
757 acpigen_write_integer(CNVI_ABORT_PLDR);
758 acpigen_emit_byte(LOCAL0_OP);
759
760 acpigen_emit_byte(AND_OP);
761 acpigen_emit_byte(LOCAL0_OP);
762 acpigen_write_integer(CNVI_ABORT_REQUEST);
763 acpigen_emit_byte(LOCAL1_OP);
764
765 acpigen_emit_byte(AND_OP);
766 acpigen_emit_byte(LOCAL0_OP);
767 acpigen_write_integer(CNVI_READY);
768 acpigen_emit_byte(LOCAL3_OP);
769
770 acpigen_write_if_lequal_op_int(LOCAL1_OP, 0);
771 {
772 acpigen_write_if_lequal_op_int(LOCAL3_OP, CNVI_READY);
773 {
774 acpigen_write_store_int_to_namestr(CNVI_PLDR_COMPLETE, "PRRS");
775 }
776 acpigen_pop_len();
777 }
778 acpigen_write_else();
779 {
780 acpigen_write_store_int_to_namestr(CNVI_PLDR_TIMEOUT, "PRRS");
781 }
782 acpigen_pop_len();
783 }
784 acpigen_write_else();
785 {
786 acpigen_write_store_int_to_namestr(CNVI_PLDR_NOT_COMPLETE, "PRRS");
787 }
788 acpigen_pop_len();
789 }
790 acpigen_pop_len();
791
792 acpigen_write_if_lequal_namestr_int("BLTS", 1);
793 {
794 acpigen_write_if_lequal_namestr_int("BLTE", 0);
795 {
796 acpigen_write_store_int_to_namestr(1, "BLTE");
797 }
798 acpigen_pop_len();
799 }
800 acpigen_pop_len();
801
802 acpigen_write_release("\\_SB.PCI0.CNMT");
803 }
804 acpigen_pop_len();
805 }
806 acpigen_pop_len();
807 }
808 acpigen_write_power_res_end();
809
810 /*
811 * Name (_PRR, Package (0x01) // _PRR: Power Resource for Reset
812 * {
813 * CNVP
814 * })
815 */
816 acpigen_write_name("_PRR");
817 {
818 acpigen_write_package(1);
819 acpigen_emit_namestring("CNVP");
820 }
821 acpigen_pop_len();
822
823 /*
824 * Method (CFLR, 0, NotSerialized)
825 * {
826 * If ((BFLR == One))
827 * {
828 * BIFR = One
829 * PRRS = One
830 * }
831 * }
832 */
833 acpigen_write_method("CFLR", 0);
834 {
835 acpigen_write_if_lequal_namestr_int("BFLR", 1);
836 {
837 acpigen_write_store_int_to_namestr(1, "BIFR");
838 acpigen_write_store_int_to_namestr(1, "PRRS");
839 }
840 acpigen_pop_len();
841 }
842 acpigen_pop_len();
843
844 acpigen_write_scope_end();
845 }
846
847 static struct device_operations cnvi_bt_ops = {
848 .read_resources = pci_dev_read_resources,
849 .set_resources = pci_dev_set_resources,
850 .enable_resources = pci_dev_enable_resources,
851 .ops_pci = &pci_dev_ops_pci,
852 .scan_bus = scan_static_bus,
853 .acpi_name = cnvi_bt_acpi_name,
854 .acpi_fill_ssdt = cnvb_fill_ssdt,
855 };
856
857 static const unsigned short bt_pci_device_ids[] = {
858 PCI_DID_INTEL_WCL_CNVI_BT,
859 PCI_DID_INTEL_PTL_H_CNVI_BT,
860 PCI_DID_INTEL_PTL_U_H_CNVI_BT,
861 PCI_DID_INTEL_TGL_CNVI_BT_0,
862 PCI_DID_INTEL_TGL_CNVI_BT_1,
863 PCI_DID_INTEL_TGL_CNVI_BT_2,
864 PCI_DID_INTEL_TGL_CNVI_BT_3,
865 PCI_DID_INTEL_TGL_H_CNVI_BT_0,
866 PCI_DID_INTEL_TGL_H_CNVI_BT_1,
867 PCI_DID_INTEL_TGL_H_CNVI_BT_2,
868 0
869 };
870
871 static const struct pci_driver pch_cnvi_bt __pci_driver = {
872 .ops = &cnvi_bt_ops,
873 .vendor = PCI_VID_INTEL,
874 .devices = bt_pci_device_ids,
875 };
876
877 static const char *cnvi_acpi_name(const struct device *dev)
878 {
879 const struct device *parent = dev->upstream->dev;
880 return parent->ops->acpi_name(parent);
881 }
882
883 static void cnvi_acpi_fill_ssdt(const struct device *dev)
884 {
885 const struct device *parent = dev->upstream->dev;
886 const char *scope = acpi_device_path(parent);
887 acpigen_write_scope(scope);
888
889 const struct soc_intel_common_block_cnvi_config *config = dev->chip_info;
890 if (config) {
891 /* Name (_PRW, Package (0x02) // _PRW: Power Resources for Wake
892 * {
893 * $(config->wake),
894 * 0x03
895 * })
896 */
897 acpigen_write_PRW(config->wake, ACPI_S3);
898 }
899 acpigen_write_scope_end();
900 }
901
902 static struct device_operations cnvi_ops = {
903 .read_resources = noop_read_resources,
904 .set_resources = noop_set_resources,
905 .acpi_fill_ssdt = cnvi_acpi_fill_ssdt,
906 .acpi_name = cnvi_acpi_name,
907 };
908
909 static void cnvi_enable_dev(struct device *dev)
910 {
911 dev->ops = &cnvi_ops;
912 }
913
914 struct chip_operations soc_intel_common_block_cnvi_ops = {
915 .name = "CNVi Device",
916 .enable_dev = cnvi_enable_dev,
917 };