acpi_isab.c revision 119418
1117339Sjhb/*- 2117339Sjhb * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org> 3117339Sjhb * All rights reserved. 4117339Sjhb * 5117339Sjhb * Redistribution and use in source and binary forms, with or without 6117339Sjhb * modification, are permitted provided that the following conditions 7117339Sjhb * are met: 8117339Sjhb * 1. Redistributions of source code must retain the above copyright 9117339Sjhb * notice, this list of conditions and the following disclaimer. 10117339Sjhb * 2. Redistributions in binary form must reproduce the above copyright 11117339Sjhb * notice, this list of conditions and the following disclaimer in the 12117339Sjhb * documentation and/or other materials provided with the distribution. 13117339Sjhb * 14117339Sjhb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15117339Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16117339Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17117339Sjhb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18117339Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19117339Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20117339Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21117339Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22117339Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23117339Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24117339Sjhb * SUCH DAMAGE. 25117339Sjhb */ 26117339Sjhb 27119418Sobrien#include <sys/cdefs.h> 28119418Sobrien__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_isab.c 119418 2003-08-24 17:55:58Z obrien $"); 29119418Sobrien 30117339Sjhb/* 31117339Sjhb * ISA Bridge driver for Generic ISA Bus Devices. See section 10.7 of the 32117339Sjhb * ACPI 2.0a specification for details on this device. 33117339Sjhb */ 34117339Sjhb 35117339Sjhb#include "opt_acpi.h" 36117339Sjhb#include <sys/param.h> 37117339Sjhb#include <sys/bus.h> 38117339Sjhb#include <sys/malloc.h> 39117339Sjhb#include <sys/kernel.h> 40117339Sjhb 41117339Sjhb#include "acpi.h" 42117339Sjhb 43117339Sjhb#include <dev/acpica/acpivar.h> 44117339Sjhb#include <isa/isavar.h> 45117339Sjhb 46117339Sjhb/* 47117339Sjhb * Hooks for the ACPI CA debugging infrastructure 48117339Sjhb */ 49117339Sjhb#define _COMPONENT ACPI_BUS 50117339SjhbACPI_MODULE_NAME("ISA_ACPI") 51117339Sjhb 52117339Sjhbstruct acpi_isab_softc { 53117339Sjhb device_t ap_dev; 54117339Sjhb ACPI_HANDLE ap_handle; 55117339Sjhb}; 56117339Sjhb 57117339Sjhb 58117339Sjhbstatic int acpi_isab_probe(device_t bus); 59117339Sjhbstatic int acpi_isab_attach(device_t bus); 60117339Sjhbstatic int acpi_isab_read_ivar(device_t dev, device_t child, int which, 61117339Sjhb uintptr_t *result); 62117339Sjhb 63117339Sjhbstatic device_method_t acpi_isab_methods[] = { 64117339Sjhb /* Device interface */ 65117339Sjhb DEVMETHOD(device_probe, acpi_isab_probe), 66117339Sjhb DEVMETHOD(device_attach, acpi_isab_attach), 67117339Sjhb DEVMETHOD(device_shutdown, bus_generic_shutdown), 68117339Sjhb DEVMETHOD(device_suspend, bus_generic_suspend), 69117339Sjhb DEVMETHOD(device_resume, bus_generic_resume), 70117339Sjhb 71117339Sjhb /* Bus interface */ 72117339Sjhb DEVMETHOD(bus_print_child, bus_generic_print_child), 73117339Sjhb DEVMETHOD(bus_read_ivar, acpi_isab_read_ivar), 74117339Sjhb DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), 75117339Sjhb DEVMETHOD(bus_release_resource, bus_generic_release_resource), 76117339Sjhb DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 77117339Sjhb DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 78117339Sjhb DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 79117339Sjhb DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 80117339Sjhb 81117339Sjhb {0, 0} 82117339Sjhb}; 83117339Sjhb 84117339Sjhbstatic driver_t acpi_isab_driver = { 85117339Sjhb "isab", 86117339Sjhb acpi_isab_methods, 87117339Sjhb sizeof(struct acpi_isab_softc), 88117339Sjhb}; 89117339Sjhb 90117339SjhbDRIVER_MODULE(acpi_isab, acpi, acpi_isab_driver, isab_devclass, 0, 0); 91117339Sjhb 92117339Sjhbstatic int 93117339Sjhbacpi_isab_probe(device_t dev) 94117339Sjhb{ 95117339Sjhb 96117339Sjhb if ((acpi_get_type(dev) == ACPI_TYPE_DEVICE) && 97117358Sjhb !acpi_disabled("isa") && 98117699Sjhb devclass_get_device(isab_devclass, 0) == dev && 99117339Sjhb (acpi_MatchHid(dev, "PNP0A05") || acpi_MatchHid(dev, "PNP0A06"))) { 100117339Sjhb device_set_desc(dev, "ACPI Generic ISA bridge"); 101117339Sjhb return(0); 102117339Sjhb } 103117339Sjhb return(ENXIO); 104117339Sjhb} 105117339Sjhb 106117339Sjhbstatic int 107117339Sjhbacpi_isab_attach(device_t dev) 108117339Sjhb{ 109117339Sjhb struct acpi_isab_softc *sc; 110117339Sjhb 111117339Sjhb ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 112117339Sjhb 113117339Sjhb sc = device_get_softc(dev); 114117339Sjhb sc->ap_dev = dev; 115117339Sjhb sc->ap_handle = acpi_get_handle(dev); 116117339Sjhb 117117339Sjhb return (isab_attach(dev)); 118117339Sjhb} 119117339Sjhb 120117339Sjhbstatic int 121117339Sjhbacpi_isab_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) 122117339Sjhb{ 123117339Sjhb struct acpi_isab_softc *sc = device_get_softc(dev); 124117339Sjhb 125117339Sjhb switch (which) { 126117339Sjhb case ACPI_IVAR_HANDLE: 127117339Sjhb *result = (uintptr_t)sc->ap_handle; 128117339Sjhb return(0); 129117339Sjhb } 130117339Sjhb return(ENOENT); 131117339Sjhb} 132