acpi_pcd.c revision 1.1
1/* $NetBSD: acpi_pcd.c,v 1.1 2020/12/07 10:57:41 jmcneill Exp $ */
2
3/*-
4 * Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca>
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 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/*
30 * This is a driver for the Processor Container Device. The device acts
31 * like a bus in the node namespace. Child nodes can be either processor
32 * devices or other processor containers.
33 */
34
35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: acpi_pcd.c,v 1.1 2020/12/07 10:57:41 jmcneill Exp $");
37
38#include <sys/param.h>
39#include <sys/bus.h>
40#include <sys/cpu.h>
41#include <sys/device.h>
42
43#include <dev/acpi/acpireg.h>
44#include <dev/acpi/acpivar.h>
45
46static const char * const compatible[] = {
47	"ACPI0010",	/* Processor Container Device */
48	NULL
49};
50
51static int	acpi_pcd_match(device_t, cfdata_t, void *);
52static void	acpi_pcd_attach(device_t, device_t, void *);
53
54CFATTACH_DECL_NEW(acpipcd, 0, acpi_pcd_match, acpi_pcd_attach, NULL, NULL);
55
56static int
57acpi_pcd_match(device_t parent, cfdata_t cf, void *aux)
58{
59	struct acpi_attach_args *aa = aux;
60
61	if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
62		return 0;
63
64	return acpi_match_hid(aa->aa_node->ad_devinfo, compatible);
65}
66
67static void
68acpi_pcd_attach(device_t parent, device_t self, void *aux)
69{
70	struct acpi_attach_args * const aa = aux;
71
72	aprint_naive("\n");
73	aprint_normal(": Processor Container Device\n");
74
75	/*
76	 * Initialize the container device. ACPICA should have done this
77	 * for us, but may have done so before a node that this one depends
78	 * on had been initialized.
79	 */
80	AcpiEvaluateObject(aa->aa_node->ad_handle, "_INI", NULL, NULL);
81}
82