Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/dev/acpica/acpi_isab.c
39536 views
1
/*-
2
* Copyright (c) 2003 John Baldwin <[email protected]>
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
6
* are met:
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
*
13
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
* SUCH DAMAGE.
24
*/
25
26
#include <sys/cdefs.h>
27
/*
28
* ISA Bridge driver for Generic ISA Bus Devices. See section 10.7 of the
29
* ACPI 2.0a specification for details on this device.
30
*/
31
32
#include "opt_acpi.h"
33
#include <sys/param.h>
34
#include <sys/bus.h>
35
#include <sys/kernel.h>
36
#include <sys/malloc.h>
37
#include <sys/module.h>
38
39
#include <contrib/dev/acpica/include/acpi.h>
40
#include <contrib/dev/acpica/include/accommon.h>
41
42
#include <dev/acpica/acpivar.h>
43
#include <isa/isavar.h>
44
45
/* Hooks for the ACPI CA debugging infrastructure. */
46
#define _COMPONENT ACPI_BUS
47
ACPI_MODULE_NAME("ISA_ACPI")
48
49
struct acpi_isab_softc {
50
device_t ap_dev;
51
ACPI_HANDLE ap_handle;
52
};
53
54
static int acpi_isab_probe(device_t bus);
55
static int acpi_isab_attach(device_t bus);
56
static int acpi_isab_read_ivar(device_t dev, device_t child, int which,
57
uintptr_t *result);
58
59
static device_method_t acpi_isab_methods[] = {
60
/* Device interface */
61
DEVMETHOD(device_probe, acpi_isab_probe),
62
DEVMETHOD(device_attach, acpi_isab_attach),
63
DEVMETHOD(device_shutdown, bus_generic_shutdown),
64
DEVMETHOD(device_suspend, bus_generic_suspend),
65
DEVMETHOD(device_resume, bus_generic_resume),
66
67
/* Bus interface */
68
DEVMETHOD(bus_read_ivar, acpi_isab_read_ivar),
69
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
70
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
71
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
72
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
73
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
74
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
75
76
DEVMETHOD_END
77
};
78
79
static driver_t acpi_isab_driver = {
80
"isab",
81
acpi_isab_methods,
82
sizeof(struct acpi_isab_softc),
83
};
84
85
DRIVER_MODULE(acpi_isab, acpi, acpi_isab_driver, 0, 0);
86
MODULE_DEPEND(acpi_isab, acpi, 1, 1, 1);
87
88
static int
89
acpi_isab_probe(device_t dev)
90
{
91
static char *isa_ids[] = { "PNP0A05", "PNP0A06", NULL };
92
int rv;
93
94
if (acpi_disabled("isab") || device_get_unit(dev) != 0)
95
return (ENXIO);
96
rv = ACPI_ID_PROBE(device_get_parent(dev), dev, isa_ids, NULL);
97
if (rv <= 0)
98
device_set_desc(dev, "ACPI Generic ISA bridge");
99
return (rv);
100
}
101
102
static int
103
acpi_isab_attach(device_t dev)
104
{
105
struct acpi_isab_softc *sc;
106
107
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
108
109
sc = device_get_softc(dev);
110
sc->ap_dev = dev;
111
sc->ap_handle = acpi_get_handle(dev);
112
113
return (isab_attach(dev));
114
}
115
116
static int
117
acpi_isab_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
118
{
119
struct acpi_isab_softc *sc = device_get_softc(dev);
120
121
switch (which) {
122
case ACPI_IVAR_HANDLE:
123
*result = (uintptr_t)sc->ap_handle;
124
return (0);
125
}
126
return (ENOENT);
127
}
128
129