acpi_cpu.c revision 1.31 1 /* $NetBSD: acpi_cpu.c,v 1.31 2011/02/27 18:32:53 jruoho Exp $ */
2
3 /*-
4 * Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen (at) iki.fi>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.31 2011/02/27 18:32:53 jruoho Exp $");
31
32 #include <sys/param.h>
33 #include <sys/cpu.h>
34 #include <sys/kernel.h>
35 #include <sys/kmem.h>
36 #include <sys/module.h>
37 #include <sys/mutex.h>
38 #include <sys/sysctl.h>
39
40 #include <dev/acpi/acpireg.h>
41 #include <dev/acpi/acpivar.h>
42 #include <dev/acpi/acpi_cpu.h>
43
44 #include <machine/acpi_machdep.h>
45 #include <machine/cpuvar.h>
46
47 #define _COMPONENT ACPI_BUS_COMPONENT
48 ACPI_MODULE_NAME ("acpi_cpu")
49
50 static int acpicpu_match(device_t, cfdata_t, void *);
51 static void acpicpu_attach(device_t, device_t, void *);
52 static int acpicpu_detach(device_t, int);
53 static int acpicpu_once_attach(void);
54 static int acpicpu_once_detach(void);
55 static void acpicpu_start(device_t);
56 static void acpicpu_debug_print(device_t);
57 static const char *acpicpu_debug_print_dep(uint32_t);
58 static void acpicpu_sysctl(device_t);
59
60 static ACPI_STATUS acpicpu_object(ACPI_HANDLE, struct acpicpu_object *);
61 static int acpicpu_find(struct cpu_info *,
62 struct acpi_devnode **);
63 static uint32_t acpicpu_cap(struct acpicpu_softc *);
64 static ACPI_STATUS acpicpu_cap_pdc(struct acpicpu_softc *, uint32_t);
65 static ACPI_STATUS acpicpu_cap_osc(struct acpicpu_softc *,
66 uint32_t, uint32_t *);
67 static void acpicpu_notify(ACPI_HANDLE, uint32_t, void *);
68 static bool acpicpu_suspend(device_t, const pmf_qual_t *);
69 static bool acpicpu_resume(device_t, const pmf_qual_t *);
70
71 static uint32_t acpicpu_count = 0;
72 struct acpicpu_softc **acpicpu_sc = NULL;
73 static struct sysctllog *acpicpu_log = NULL;
74 static bool acpicpu_dynamic = true;
75 static bool acpicpu_passive = true;
76
77 static const char * const acpicpu_hid[] = {
78 "ACPI0007",
79 NULL
80 };
81
82 CFATTACH_DECL_NEW(acpicpu, sizeof(struct acpicpu_softc),
83 acpicpu_match, acpicpu_attach, acpicpu_detach, NULL);
84
85 static int
86 acpicpu_match(device_t parent, cfdata_t match, void *aux)
87 {
88 struct cpu_info *ci;
89
90 if (acpi_softc == NULL)
91 return 0;
92
93 ci = acpicpu_md_match(parent, match, aux);
94
95 if (ci == NULL)
96 return 0;
97
98 return acpicpu_find(ci, NULL);
99 }
100
101 static void
102 acpicpu_attach(device_t parent, device_t self, void *aux)
103 {
104 struct acpicpu_softc *sc = device_private(self);
105 struct cpu_info *ci;
106 cpuid_t id;
107 int rv;
108
109 ci = acpicpu_md_attach(parent, self, aux);
110
111 if (ci == NULL)
112 return;
113
114 sc->sc_ci = ci;
115 sc->sc_dev = self;
116 sc->sc_cold = true;
117 sc->sc_node = NULL;
118
119 rv = acpicpu_find(ci, &sc->sc_node);
120
121 if (rv == 0) {
122 aprint_normal(": failed to match processor\n");
123 return;
124 }
125
126 if (acpicpu_once_attach() != 0) {
127 aprint_normal(": failed to initialize\n");
128 return;
129 }
130
131 KASSERT(acpi_softc != NULL);
132 KASSERT(acpicpu_sc != NULL);
133 KASSERT(sc->sc_node != NULL);
134
135 id = sc->sc_ci->ci_acpiid;
136
137 if (acpicpu_sc[id] != NULL) {
138 aprint_normal(": already attached\n");
139 return;
140 }
141
142 aprint_naive("\n");
143 aprint_normal(": ACPI CPU\n");
144
145 rv = acpicpu_object(sc->sc_node->ad_handle, &sc->sc_object);
146
147 if (ACPI_FAILURE(rv))
148 aprint_verbose_dev(self, "failed to obtain CPU object\n");
149
150 acpicpu_count++;
151 acpicpu_sc[id] = sc;
152
153 sc->sc_cap = acpicpu_cap(sc);
154 sc->sc_ncpus = acpi_md_ncpus();
155 sc->sc_flags = acpicpu_md_flags();
156
157 KASSERT(acpicpu_count <= sc->sc_ncpus);
158 KASSERT(sc->sc_node->ad_device == NULL);
159
160 sc->sc_node->ad_device = self;
161 mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_NONE);
162
163 acpicpu_cstate_attach(self);
164 acpicpu_pstate_attach(self);
165 acpicpu_tstate_attach(self);
166
167 acpicpu_debug_print(self);
168
169 (void)config_interrupts(self, acpicpu_start);
170 (void)acpi_register_notify(sc->sc_node, acpicpu_notify);
171 (void)pmf_device_register(self, acpicpu_suspend, acpicpu_resume);
172 }
173
174 static int
175 acpicpu_detach(device_t self, int flags)
176 {
177 struct acpicpu_softc *sc = device_private(self);
178 int rv = 0;
179
180 sc->sc_cold = true;
181 acpi_deregister_notify(sc->sc_node);
182
183 if ((sc->sc_flags & ACPICPU_FLAG_C) != 0)
184 rv = acpicpu_cstate_detach(self);
185
186 if (rv != 0)
187 return rv;
188
189 if ((sc->sc_flags & ACPICPU_FLAG_P) != 0)
190 rv = acpicpu_pstate_detach(self);
191
192 if (rv != 0)
193 return rv;
194
195 if ((sc->sc_flags & ACPICPU_FLAG_T) != 0)
196 rv = acpicpu_tstate_detach(self);
197
198 if (rv != 0)
199 return rv;
200
201 mutex_destroy(&sc->sc_mtx);
202 sc->sc_node->ad_device = NULL;
203
204 acpicpu_count--;
205 acpicpu_once_detach();
206
207 return 0;
208 }
209
210 static int
211 acpicpu_once_attach(void)
212 {
213 struct acpicpu_softc *sc;
214 unsigned int i;
215
216 if (acpicpu_count != 0)
217 return 0;
218
219 KASSERT(acpicpu_sc == NULL);
220 KASSERT(acpicpu_log == NULL);
221
222 acpicpu_sc = kmem_zalloc(maxcpus * sizeof(*sc), KM_SLEEP);
223
224 if (acpicpu_sc == NULL)
225 return ENOMEM;
226
227 for (i = 0; i < maxcpus; i++)
228 acpicpu_sc[i] = NULL;
229
230 return 0;
231 }
232
233 static int
234 acpicpu_once_detach(void)
235 {
236 struct acpicpu_softc *sc;
237
238 if (acpicpu_count != 0)
239 return EDEADLK;
240
241 if (acpicpu_log != NULL)
242 sysctl_teardown(&acpicpu_log);
243
244 if (acpicpu_sc != NULL)
245 kmem_free(acpicpu_sc, maxcpus * sizeof(*sc));
246
247 return 0;
248 }
249
250 static void
251 acpicpu_start(device_t self)
252 {
253 struct acpicpu_softc *sc = device_private(self);
254 static uint32_t count = 0;
255
256 /*
257 * Run the state-specific initialization routines. These
258 * must run only once, after interrupts have been enabled,
259 * all CPUs are running, and all ACPI CPUs have attached.
260 */
261 if (++count != acpicpu_count || acpicpu_count != sc->sc_ncpus) {
262 sc->sc_cold = false;
263 return;
264 }
265
266 /*
267 * Set the last ACPI CPU as non-cold
268 * only after C-states are enabled.
269 */
270 if ((sc->sc_flags & ACPICPU_FLAG_C) != 0)
271 acpicpu_cstate_start(self);
272
273 sc->sc_cold = false;
274
275 if ((sc->sc_flags & ACPICPU_FLAG_P) != 0)
276 acpicpu_pstate_start(self);
277
278 if ((sc->sc_flags & ACPICPU_FLAG_T) != 0)
279 acpicpu_tstate_start(self);
280
281 acpicpu_sysctl(self);
282 aprint_debug_dev(self, "ACPI CPUs started\n");
283 }
284
285 static void
286 acpicpu_sysctl(device_t self)
287 {
288 const struct sysctlnode *node;
289 int err;
290
291 KASSERT(acpicpu_log == NULL);
292
293 err = sysctl_createv(&acpicpu_log, 0, NULL, &node,
294 CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", NULL,
295 NULL, 0, NULL, 0, CTL_HW, CTL_EOL);
296
297 if (err != 0)
298 goto fail;
299
300 err = sysctl_createv(&acpicpu_log, 0, &node, &node,
301 CTLFLAG_PERMANENT, CTLTYPE_NODE, "acpi", NULL,
302 NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
303
304 if (err != 0)
305 goto fail;
306
307 err = sysctl_createv(&acpicpu_log, 0, &node, &node,
308 0, CTLTYPE_NODE, "cpu", SYSCTL_DESCR("ACPI CPU"),
309 NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
310
311 if (err != 0)
312 goto fail;
313
314 err = sysctl_createv(&acpicpu_log, 0, &node, NULL,
315 CTLFLAG_READWRITE, CTLTYPE_BOOL, "dynamic",
316 SYSCTL_DESCR("Dynamic states"), NULL, 0,
317 &acpicpu_dynamic, 0, CTL_CREATE, CTL_EOL);
318
319 if (err != 0)
320 goto fail;
321
322 err = sysctl_createv(&acpicpu_log, 0, &node, NULL,
323 CTLFLAG_READWRITE, CTLTYPE_BOOL, "passive",
324 SYSCTL_DESCR("Passive cooling"), NULL, 0,
325 &acpicpu_passive, 0, CTL_CREATE, CTL_EOL);
326
327 if (err != 0)
328 goto fail;
329
330 return;
331
332 fail:
333 aprint_error_dev(self, "failed to initialize sysctl (err %d)\n", err);
334 }
335
336 static ACPI_STATUS
337 acpicpu_object(ACPI_HANDLE hdl, struct acpicpu_object *ao)
338 {
339 ACPI_OBJECT *obj;
340 ACPI_BUFFER buf;
341 ACPI_STATUS rv;
342
343 rv = acpi_eval_struct(hdl, NULL, &buf);
344
345 if (ACPI_FAILURE(rv))
346 goto out;
347
348 obj = buf.Pointer;
349
350 if (obj->Type != ACPI_TYPE_PROCESSOR) {
351 rv = AE_TYPE;
352 goto out;
353 }
354
355 if (obj->Processor.ProcId > (uint32_t)maxcpus) {
356 rv = AE_LIMIT;
357 goto out;
358 }
359
360 KDASSERT((uint64_t)obj->Processor.PblkAddress < UINT32_MAX);
361
362 if (ao != NULL) {
363 ao->ao_procid = obj->Processor.ProcId;
364 ao->ao_pblklen = obj->Processor.PblkLength;
365 ao->ao_pblkaddr = obj->Processor.PblkAddress;
366 }
367
368 out:
369 if (buf.Pointer != NULL)
370 ACPI_FREE(buf.Pointer);
371
372 return rv;
373 }
374
375 static int
376 acpicpu_find(struct cpu_info *ci, struct acpi_devnode **ptr)
377 {
378 struct acpi_softc *sc = acpi_softc;
379 struct acpicpu_object ao;
380 struct acpi_devnode *ad;
381 ACPI_INTEGER val;
382 ACPI_STATUS rv;
383
384 if (sc == NULL || acpi_active == 0)
385 return 0;
386
387 /*
388 * CPUs are declared in the ACPI namespace
389 * either as a Processor() or as a Device().
390 * In both cases the MADT entries are used
391 * for the match (see ACPI 4.0, section 8.4).
392 */
393 SIMPLEQ_FOREACH(ad, &sc->ad_head, ad_list) {
394
395 if (ad->ad_type == ACPI_TYPE_PROCESSOR) {
396
397 rv = acpicpu_object(ad->ad_handle, &ao);
398
399 if (ACPI_SUCCESS(rv) && ci->ci_acpiid == ao.ao_procid)
400 goto out;
401 }
402
403 if (acpi_match_hid(ad->ad_devinfo, acpicpu_hid) != 0) {
404
405 rv = acpi_eval_integer(ad->ad_handle, "_UID", &val);
406
407 if (ACPI_SUCCESS(rv) && ci->ci_acpiid == val)
408 goto out;
409 }
410 }
411
412 return 0;
413
414 out:
415 if (ptr != NULL)
416 *ptr = ad;
417
418 return 10;
419 }
420
421 static uint32_t
422 acpicpu_cap(struct acpicpu_softc *sc)
423 {
424 uint32_t flags, cap = 0;
425 const char *str;
426 ACPI_STATUS rv;
427
428 /*
429 * Query and set machine-dependent capabilities.
430 * Note that the Intel-specific _PDC method was
431 * deprecated in the ACPI 3.0 in favor of _OSC.
432 */
433 flags = acpicpu_md_cap();
434 rv = acpicpu_cap_osc(sc, flags, &cap);
435
436 if (ACPI_FAILURE(rv) && rv != AE_NOT_FOUND) {
437 str = "_OSC";
438 goto fail;
439 }
440
441 rv = acpicpu_cap_pdc(sc, flags);
442
443 if (ACPI_FAILURE(rv) && rv != AE_NOT_FOUND) {
444 str = "_PDC";
445 goto fail;
446 }
447
448 if (cap == 0)
449 cap = flags;
450
451 return cap;
452
453 fail:
454 aprint_error_dev(sc->sc_dev, "failed to evaluate "
455 "%s: %s\n", str, AcpiFormatException(rv));
456
457 return 0;
458 }
459
460 static ACPI_STATUS
461 acpicpu_cap_pdc(struct acpicpu_softc *sc, uint32_t flags)
462 {
463 ACPI_OBJECT_LIST arg;
464 ACPI_OBJECT obj;
465 uint32_t cap[3];
466
467 arg.Count = 1;
468 arg.Pointer = &obj;
469
470 cap[0] = ACPICPU_PDC_REVID;
471 cap[1] = 1;
472 cap[2] = flags;
473
474 obj.Type = ACPI_TYPE_BUFFER;
475 obj.Buffer.Length = sizeof(cap);
476 obj.Buffer.Pointer = (void *)cap;
477
478 return AcpiEvaluateObject(sc->sc_node->ad_handle, "_PDC", &arg, NULL);
479 }
480
481 static ACPI_STATUS
482 acpicpu_cap_osc(struct acpicpu_softc *sc, uint32_t flags, uint32_t *val)
483 {
484 ACPI_OBJECT_LIST arg;
485 ACPI_OBJECT obj[4];
486 ACPI_OBJECT *osc;
487 ACPI_BUFFER buf;
488 ACPI_STATUS rv;
489 uint32_t cap[2];
490 uint32_t *ptr;
491 int i = 5;
492
493 static uint8_t intel_uuid[16] = {
494 0x16, 0xA6, 0x77, 0x40, 0x0C, 0x29, 0xBE, 0x47,
495 0x9E, 0xBD, 0xD8, 0x70, 0x58, 0x71, 0x39, 0x53
496 };
497
498 cap[0] = ACPI_OSC_QUERY;
499 cap[1] = flags;
500
501 again:
502 arg.Count = 4;
503 arg.Pointer = obj;
504
505 obj[0].Type = ACPI_TYPE_BUFFER;
506 obj[0].Buffer.Length = sizeof(intel_uuid);
507 obj[0].Buffer.Pointer = intel_uuid;
508
509 obj[1].Type = ACPI_TYPE_INTEGER;
510 obj[1].Integer.Value = ACPICPU_PDC_REVID;
511
512 obj[2].Type = ACPI_TYPE_INTEGER;
513 obj[2].Integer.Value = __arraycount(cap);
514
515 obj[3].Type = ACPI_TYPE_BUFFER;
516 obj[3].Buffer.Length = sizeof(cap);
517 obj[3].Buffer.Pointer = (void *)cap;
518
519 buf.Pointer = NULL;
520 buf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
521
522 rv = AcpiEvaluateObject(sc->sc_node->ad_handle, "_OSC", &arg, &buf);
523
524 if (ACPI_FAILURE(rv))
525 goto out;
526
527 osc = buf.Pointer;
528
529 if (osc->Type != ACPI_TYPE_BUFFER) {
530 rv = AE_TYPE;
531 goto out;
532 }
533
534 if (osc->Buffer.Length != sizeof(cap)) {
535 rv = AE_BUFFER_OVERFLOW;
536 goto out;
537 }
538
539 ptr = (uint32_t *)osc->Buffer.Pointer;
540
541 if ((ptr[0] & ACPI_OSC_ERROR) != 0) {
542 rv = AE_ERROR;
543 goto out;
544 }
545
546 if ((ptr[0] & (ACPI_OSC_ERROR_REV | ACPI_OSC_ERROR_UUID)) != 0) {
547 rv = AE_BAD_PARAMETER;
548 goto out;
549 }
550
551 /*
552 * "It is strongly recommended that the OS evaluate
553 * _OSC with the Query Support Flag set until _OSC
554 * returns the Capabilities Masked bit clear, to
555 * negotiate the set of features to be granted to
556 * the OS for native support (ACPI 4.0, 6.2.10)."
557 */
558 if ((ptr[0] & ACPI_OSC_ERROR_MASKED) != 0 && i >= 0) {
559
560 ACPI_FREE(buf.Pointer);
561 i--;
562
563 goto again;
564 }
565
566 if ((cap[0] & ACPI_OSC_QUERY) != 0) {
567
568 ACPI_FREE(buf.Pointer);
569 cap[0] &= ~ACPI_OSC_QUERY;
570
571 goto again;
572 }
573
574 /*
575 * It is permitted for _OSC to return all
576 * bits cleared, but this is specified to
577 * vary on per-device basis. Assume that
578 * everything rather than nothing will be
579 * supported in this case; we do not need
580 * the firmware to know the CPU features.
581 */
582 *val = (ptr[1] != 0) ? ptr[1] : cap[1];
583
584 out:
585 if (buf.Pointer != NULL)
586 ACPI_FREE(buf.Pointer);
587
588 return rv;
589 }
590
591 static void
592 acpicpu_notify(ACPI_HANDLE hdl, uint32_t evt, void *aux)
593 {
594 ACPI_OSD_EXEC_CALLBACK func;
595 struct acpicpu_softc *sc;
596 device_t self = aux;
597
598 sc = device_private(self);
599
600 if (sc->sc_cold != false)
601 return;
602
603 if (acpicpu_dynamic != true)
604 return;
605
606 switch (evt) {
607
608 case ACPICPU_C_NOTIFY:
609
610 if ((sc->sc_flags & ACPICPU_FLAG_C) == 0)
611 return;
612
613 func = acpicpu_cstate_callback;
614 break;
615
616 case ACPICPU_P_NOTIFY:
617
618 if ((sc->sc_flags & ACPICPU_FLAG_P) == 0)
619 return;
620
621 func = acpicpu_pstate_callback;
622 break;
623
624 case ACPICPU_T_NOTIFY:
625
626 if ((sc->sc_flags & ACPICPU_FLAG_T) == 0)
627 return;
628
629 func = acpicpu_tstate_callback;
630 break;
631
632 default:
633 aprint_error_dev(sc->sc_dev, "unknown notify: 0x%02X\n", evt);
634 return;
635 }
636
637 (void)AcpiOsExecute(OSL_NOTIFY_HANDLER, func, sc->sc_dev);
638 }
639
640 static bool
641 acpicpu_suspend(device_t self, const pmf_qual_t *qual)
642 {
643 struct acpicpu_softc *sc = device_private(self);
644
645 if ((sc->sc_flags & ACPICPU_FLAG_C) != 0)
646 (void)acpicpu_cstate_suspend(self);
647
648 if ((sc->sc_flags & ACPICPU_FLAG_P) != 0)
649 (void)acpicpu_pstate_suspend(self);
650
651 if ((sc->sc_flags & ACPICPU_FLAG_T) != 0)
652 (void)acpicpu_tstate_suspend(self);
653
654 sc->sc_cold = true;
655
656 return true;
657 }
658
659 static bool
660 acpicpu_resume(device_t self, const pmf_qual_t *qual)
661 {
662 struct acpicpu_softc *sc = device_private(self);
663
664 sc->sc_cold = false;
665
666 if ((sc->sc_flags & ACPICPU_FLAG_C) != 0)
667 (void)acpicpu_cstate_resume(self);
668
669 if ((sc->sc_flags & ACPICPU_FLAG_P) != 0)
670 (void)acpicpu_pstate_resume(self);
671
672 if ((sc->sc_flags & ACPICPU_FLAG_T) != 0)
673 (void)acpicpu_tstate_resume(self);
674
675 return true;
676 }
677
678 static void
679 acpicpu_debug_print(device_t self)
680 {
681 struct acpicpu_softc *sc = device_private(self);
682 struct cpu_info *ci = sc->sc_ci;
683 struct acpicpu_dep *dep;
684
685 aprint_debug_dev(sc->sc_dev, "id %u, lapic id %u, "
686 "cap 0x%04x, flags 0x%08x\n", ci->ci_acpiid,
687 (uint32_t)ci->ci_cpuid, sc->sc_cap, sc->sc_flags);
688
689 if ((sc->sc_flags & ACPICPU_FLAG_C_DEP) != 0) {
690
691 dep = &sc->sc_cstate_dep;
692
693 aprint_debug_dev(sc->sc_dev, "C-state coordination: "
694 "%u CPUs, domain %u, type %s\n", dep->dep_ncpus,
695 dep->dep_domain, acpicpu_debug_print_dep(dep->dep_type));
696 }
697
698 if ((sc->sc_flags & ACPICPU_FLAG_P_DEP) != 0) {
699
700 dep = &sc->sc_pstate_dep;
701
702 aprint_debug_dev(sc->sc_dev, "P-state coordination: "
703 "%u CPUs, domain %u, type %s\n", dep->dep_ncpus,
704 dep->dep_domain, acpicpu_debug_print_dep(dep->dep_type));
705 }
706
707 if ((sc->sc_flags & ACPICPU_FLAG_T_DEP) != 0) {
708
709 dep = &sc->sc_tstate_dep;
710
711 aprint_debug_dev(sc->sc_dev, "T-state coordination: "
712 "%u CPUs, domain %u, type %s\n", dep->dep_ncpus,
713 dep->dep_domain, acpicpu_debug_print_dep(dep->dep_type));
714 }
715 }
716
717 static const char *
718 acpicpu_debug_print_dep(uint32_t val)
719 {
720
721 switch (val) {
722
723 case ACPICPU_DEP_SW_ALL:
724 return "SW_ALL";
725
726 case ACPICPU_DEP_SW_ANY:
727 return "SW_ANY";
728
729 case ACPICPU_DEP_HW_ALL:
730 return "HW_ALL";
731
732 default:
733 return "unknown";
734 }
735 }
736
737 MODULE(MODULE_CLASS_DRIVER, acpicpu, NULL);
738
739 #ifdef _MODULE
740 #include "ioconf.c"
741 #endif
742
743 static int
744 acpicpu_modcmd(modcmd_t cmd, void *aux)
745 {
746 int rv = 0;
747
748 switch (cmd) {
749
750 case MODULE_CMD_INIT:
751
752 #ifdef _MODULE
753 rv = config_init_component(cfdriver_ioconf_acpicpu,
754 cfattach_ioconf_acpicpu, cfdata_ioconf_acpicpu);
755 #endif
756 break;
757
758 case MODULE_CMD_FINI:
759
760 #ifdef _MODULE
761 rv = config_fini_component(cfdriver_ioconf_acpicpu,
762 cfattach_ioconf_acpicpu, cfdata_ioconf_acpicpu);
763 #endif
764 break;
765
766 default:
767 rv = ENOTTY;
768 }
769
770 return rv;
771 }
772