acpi_pcd.c revision 1.1
11.1Sjmcneill/* $NetBSD: acpi_pcd.c,v 1.1 2020/12/07 10:57:41 jmcneill Exp $ */ 21.1Sjmcneill 31.1Sjmcneill/*- 41.1Sjmcneill * Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca> 51.1Sjmcneill * All rights reserved. 61.1Sjmcneill * 71.1Sjmcneill * Redistribution and use in source and binary forms, with or without 81.1Sjmcneill * modification, are permitted provided that the following conditions 91.1Sjmcneill * are met: 101.1Sjmcneill * 1. Redistributions of source code must retain the above copyright 111.1Sjmcneill * notice, this list of conditions and the following disclaimer. 121.1Sjmcneill * 2. Redistributions in binary form must reproduce the above copyright 131.1Sjmcneill * notice, this list of conditions and the following disclaimer in the 141.1Sjmcneill * documentation and/or other materials provided with the distribution. 151.1Sjmcneill * 161.1Sjmcneill * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 171.1Sjmcneill * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 181.1Sjmcneill * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 191.1Sjmcneill * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 201.1Sjmcneill * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 211.1Sjmcneill * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 221.1Sjmcneill * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 231.1Sjmcneill * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 241.1Sjmcneill * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 251.1Sjmcneill * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 261.1Sjmcneill * POSSIBILITY OF SUCH DAMAGE. 271.1Sjmcneill */ 281.1Sjmcneill 291.1Sjmcneill/* 301.1Sjmcneill * This is a driver for the Processor Container Device. The device acts 311.1Sjmcneill * like a bus in the node namespace. Child nodes can be either processor 321.1Sjmcneill * devices or other processor containers. 331.1Sjmcneill */ 341.1Sjmcneill 351.1Sjmcneill#include <sys/cdefs.h> 361.1Sjmcneill__KERNEL_RCSID(0, "$NetBSD: acpi_pcd.c,v 1.1 2020/12/07 10:57:41 jmcneill Exp $"); 371.1Sjmcneill 381.1Sjmcneill#include <sys/param.h> 391.1Sjmcneill#include <sys/bus.h> 401.1Sjmcneill#include <sys/cpu.h> 411.1Sjmcneill#include <sys/device.h> 421.1Sjmcneill 431.1Sjmcneill#include <dev/acpi/acpireg.h> 441.1Sjmcneill#include <dev/acpi/acpivar.h> 451.1Sjmcneill 461.1Sjmcneillstatic const char * const compatible[] = { 471.1Sjmcneill "ACPI0010", /* Processor Container Device */ 481.1Sjmcneill NULL 491.1Sjmcneill}; 501.1Sjmcneill 511.1Sjmcneillstatic int acpi_pcd_match(device_t, cfdata_t, void *); 521.1Sjmcneillstatic void acpi_pcd_attach(device_t, device_t, void *); 531.1Sjmcneill 541.1SjmcneillCFATTACH_DECL_NEW(acpipcd, 0, acpi_pcd_match, acpi_pcd_attach, NULL, NULL); 551.1Sjmcneill 561.1Sjmcneillstatic int 571.1Sjmcneillacpi_pcd_match(device_t parent, cfdata_t cf, void *aux) 581.1Sjmcneill{ 591.1Sjmcneill struct acpi_attach_args *aa = aux; 601.1Sjmcneill 611.1Sjmcneill if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE) 621.1Sjmcneill return 0; 631.1Sjmcneill 641.1Sjmcneill return acpi_match_hid(aa->aa_node->ad_devinfo, compatible); 651.1Sjmcneill} 661.1Sjmcneill 671.1Sjmcneillstatic void 681.1Sjmcneillacpi_pcd_attach(device_t parent, device_t self, void *aux) 691.1Sjmcneill{ 701.1Sjmcneill struct acpi_attach_args * const aa = aux; 711.1Sjmcneill 721.1Sjmcneill aprint_naive("\n"); 731.1Sjmcneill aprint_normal(": Processor Container Device\n"); 741.1Sjmcneill 751.1Sjmcneill /* 761.1Sjmcneill * Initialize the container device. ACPICA should have done this 771.1Sjmcneill * for us, but may have done so before a node that this one depends 781.1Sjmcneill * on had been initialized. 791.1Sjmcneill */ 801.1Sjmcneill AcpiEvaluateObject(aa->aa_node->ad_handle, "_INI", NULL, NULL); 811.1Sjmcneill} 82