| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: acpi_fan.c,v 1.1 2011/01/09 15:12:34 jruoho Exp $ */ | | 1 | /* $NetBSD: acpi_fan.c,v 1.2 2011/01/09 15:43:20 jruoho Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi> | | 4 | * Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * | | 10 | * |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | | 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 | | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | | 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 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 | | 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 | | 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 | | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 | * SUCH DAMAGE. | | 27 | * SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: acpi_fan.c,v 1.1 2011/01/09 15:12:34 jruoho Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: acpi_fan.c,v 1.2 2011/01/09 15:43:20 jruoho Exp $"); |
31 | | | 31 | |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/module.h> | | 33 | #include <sys/module.h> |
34 | | | 34 | |
35 | #include <dev/acpi/acpireg.h> | | 35 | #include <dev/acpi/acpireg.h> |
36 | #include <dev/acpi/acpivar.h> | | 36 | #include <dev/acpi/acpivar.h> |
37 | #include <dev/acpi/acpi_power.h> | | 37 | #include <dev/acpi/acpi_power.h> |
38 | | | 38 | |
39 | #include <dev/sysmon/sysmonvar.h> | | 39 | #include <dev/sysmon/sysmonvar.h> |
40 | | | 40 | |
41 | #define _COMPONENT ACPI_RESOURCE_COMPONENT | | 41 | #define _COMPONENT ACPI_RESOURCE_COMPONENT |
42 | ACPI_MODULE_NAME ("acpi_fan") | | 42 | ACPI_MODULE_NAME ("acpi_fan") |
43 | | | 43 | |
| @@ -102,26 +102,29 @@ acpifan_attach(device_t parent, device_t | | | @@ -102,26 +102,29 @@ acpifan_attach(device_t parent, device_t |
102 | acpifan_resume, acpifan_shutdown); | | 102 | acpifan_resume, acpifan_shutdown); |
103 | | | 103 | |
104 | rv = AcpiGetHandle(sc->sc_node->ad_handle, "_FIF", &tmp); | | 104 | rv = AcpiGetHandle(sc->sc_node->ad_handle, "_FIF", &tmp); |
105 | | | 105 | |
106 | if (ACPI_SUCCESS(rv)) | | 106 | if (ACPI_SUCCESS(rv)) |
107 | aprint_verbose_dev(self, "ACPI 4.0 functionality present\n"); | | 107 | aprint_verbose_dev(self, "ACPI 4.0 functionality present\n"); |
108 | } | | 108 | } |
109 | | | 109 | |
110 | static int | | 110 | static int |
111 | acpifan_detach(device_t self, int flags) | | 111 | acpifan_detach(device_t self, int flags) |
112 | { | | 112 | { |
113 | struct acpifan_softc *sc = device_private(self); | | 113 | struct acpifan_softc *sc = device_private(self); |
114 | | | 114 | |
| | | 115 | if (sc->sc_state != ACPI_STATE_ERROR) |
| | | 116 | (void)acpi_power_set(sc->sc_node->ad_handle, ACPI_STATE_D0); |
| | | 117 | |
115 | pmf_device_deregister(self); | | 118 | pmf_device_deregister(self); |
116 | acpi_power_deregister(sc->sc_node->ad_handle); | | 119 | acpi_power_deregister(sc->sc_node->ad_handle); |
117 | | | 120 | |
118 | if (sc->sc_sme != NULL) | | 121 | if (sc->sc_sme != NULL) |
119 | sysmon_envsys_unregister(sc->sc_sme); | | 122 | sysmon_envsys_unregister(sc->sc_sme); |
120 | | | 123 | |
121 | return 0; | | 124 | return 0; |
122 | } | | 125 | } |
123 | | | 126 | |
124 | static bool | | 127 | static bool |
125 | acpifan_suspend(device_t self, const pmf_qual_t *qual) | | 128 | acpifan_suspend(device_t self, const pmf_qual_t *qual) |
126 | { | | 129 | { |
127 | struct acpifan_softc *sc = device_private(self); | | 130 | struct acpifan_softc *sc = device_private(self); |
| @@ -142,27 +145,27 @@ acpifan_resume(device_t self, const pmf_ | | | @@ -142,27 +145,27 @@ acpifan_resume(device_t self, const pmf_ |
142 | | | 145 | |
143 | if (sc->sc_state != ACPI_STATE_ERROR) | | 146 | if (sc->sc_state != ACPI_STATE_ERROR) |
144 | (void)acpi_power_set(sc->sc_node->ad_handle, sc->sc_state); | | 147 | (void)acpi_power_set(sc->sc_node->ad_handle, sc->sc_state); |
145 | | | 148 | |
146 | return true; | | 149 | return true; |
147 | } | | 150 | } |
148 | | | 151 | |
149 | static bool | | 152 | static bool |
150 | acpifan_shutdown(device_t self, int how) | | 153 | acpifan_shutdown(device_t self, int how) |
151 | { | | 154 | { |
152 | struct acpifan_softc *sc = device_private(self); | | 155 | struct acpifan_softc *sc = device_private(self); |
153 | | | 156 | |
154 | if (sc->sc_state != ACPI_STATE_ERROR) | | 157 | if (sc->sc_state != ACPI_STATE_ERROR) |
155 | (void)acpi_power_set(sc->sc_node->ad_handle, ACPI_STATE_D3); | | 158 | (void)acpi_power_set(sc->sc_node->ad_handle, ACPI_STATE_D0); |
156 | | | 159 | |
157 | return true; | | 160 | return true; |
158 | } | | 161 | } |
159 | | | 162 | |
160 | static bool | | 163 | static bool |
161 | acpifan_sensor_init(device_t self) | | 164 | acpifan_sensor_init(device_t self) |
162 | { | | 165 | { |
163 | struct acpifan_softc *sc = device_private(self); | | 166 | struct acpifan_softc *sc = device_private(self); |
164 | | | 167 | |
165 | if (acpi_power_get(sc->sc_node->ad_handle, &sc->sc_state) != true) | | 168 | if (acpi_power_get(sc->sc_node->ad_handle, &sc->sc_state) != true) |
166 | return false; | | 169 | return false; |
167 | | | 170 | |
168 | sc->sc_sme = sysmon_envsys_create(); | | 171 | sc->sc_sme = sysmon_envsys_create(); |