| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: acpi_bat.c,v 1.106 2011/01/04 05:48:48 jruoho Exp $ */ | | 1 | /* $NetBSD: acpi_bat.c,v 1.107 2011/01/09 09:47:55 jruoho Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Charles M. Hannum of By Noon Software, Inc. | | 8 | * by Charles M. Hannum of By Noon Software, Inc. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -65,27 +65,27 @@ | | | @@ -65,27 +65,27 @@ |
65 | /* | | 65 | /* |
66 | * ACPI Battery Driver. | | 66 | * ACPI Battery Driver. |
67 | * | | 67 | * |
68 | * ACPI defines two different battery device interfaces: "Control | | 68 | * ACPI defines two different battery device interfaces: "Control |
69 | * Method" batteries, in which AML methods are defined in order to get | | 69 | * Method" batteries, in which AML methods are defined in order to get |
70 | * battery status and set battery alarm thresholds, and a "Smart | | 70 | * battery status and set battery alarm thresholds, and a "Smart |
71 | * Battery" device, which is an SMbus device accessed through the ACPI | | 71 | * Battery" device, which is an SMbus device accessed through the ACPI |
72 | * Embedded Controller device. | | 72 | * Embedded Controller device. |
73 | * | | 73 | * |
74 | * This driver is for the "Control Method"-style battery only. | | 74 | * This driver is for the "Control Method"-style battery only. |
75 | */ | | 75 | */ |
76 | | | 76 | |
77 | #include <sys/cdefs.h> | | 77 | #include <sys/cdefs.h> |
78 | __KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.106 2011/01/04 05:48:48 jruoho Exp $"); | | 78 | __KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.107 2011/01/09 09:47:55 jruoho Exp $"); |
79 | | | 79 | |
80 | #include <sys/param.h> | | 80 | #include <sys/param.h> |
81 | #include <sys/condvar.h> | | 81 | #include <sys/condvar.h> |
82 | #include <sys/device.h> | | 82 | #include <sys/device.h> |
83 | #include <sys/kernel.h> | | 83 | #include <sys/kernel.h> |
84 | #include <sys/kmem.h> | | 84 | #include <sys/kmem.h> |
85 | #include <sys/module.h> | | 85 | #include <sys/module.h> |
86 | #include <sys/mutex.h> | | 86 | #include <sys/mutex.h> |
87 | #include <sys/systm.h> | | 87 | #include <sys/systm.h> |
88 | | | 88 | |
89 | #include <dev/acpi/acpireg.h> | | 89 | #include <dev/acpi/acpireg.h> |
90 | #include <dev/acpi/acpivar.h> | | 90 | #include <dev/acpi/acpivar.h> |
91 | | | 91 | |
| @@ -211,26 +211,28 @@ acpibat_match(device_t parent, cfdata_t | | | @@ -211,26 +211,28 @@ acpibat_match(device_t parent, cfdata_t |
211 | return acpi_match_hid(aa->aa_node->ad_devinfo, bat_hid); | | 211 | return acpi_match_hid(aa->aa_node->ad_devinfo, bat_hid); |
212 | } | | 212 | } |
213 | | | 213 | |
214 | /* | | 214 | /* |
215 | * acpibat_attach: | | 215 | * acpibat_attach: |
216 | * | | 216 | * |
217 | * Autoconfiguration `attach' routine. | | 217 | * Autoconfiguration `attach' routine. |
218 | */ | | 218 | */ |
219 | static void | | 219 | static void |
220 | acpibat_attach(device_t parent, device_t self, void *aux) | | 220 | acpibat_attach(device_t parent, device_t self, void *aux) |
221 | { | | 221 | { |
222 | struct acpibat_softc *sc = device_private(self); | | 222 | struct acpibat_softc *sc = device_private(self); |
223 | struct acpi_attach_args *aa = aux; | | 223 | struct acpi_attach_args *aa = aux; |
| | | 224 | ACPI_HANDLE tmp; |
| | | 225 | ACPI_STATUS rv; |
224 | | | 226 | |
225 | aprint_naive(": ACPI Battery\n"); | | 227 | aprint_naive(": ACPI Battery\n"); |
226 | aprint_normal(": ACPI Battery\n"); | | 228 | aprint_normal(": ACPI Battery\n"); |
227 | | | 229 | |
228 | sc->sc_node = aa->aa_node; | | 230 | sc->sc_node = aa->aa_node; |
229 | | | 231 | |
230 | sc->sc_present = 0; | | 232 | sc->sc_present = 0; |
231 | sc->sc_lcapacity = 0; | | 233 | sc->sc_lcapacity = 0; |
232 | sc->sc_wcapacity = 0; | | 234 | sc->sc_wcapacity = 0; |
233 | | | 235 | |
234 | sc->sc_sme = NULL; | | 236 | sc->sc_sme = NULL; |
235 | sc->sc_sensor = NULL; | | 237 | sc->sc_sensor = NULL; |
236 | | | 238 | |
| @@ -238,26 +240,34 @@ acpibat_attach(device_t parent, device_t | | | @@ -238,26 +240,34 @@ acpibat_attach(device_t parent, device_t |
238 | cv_init(&sc->sc_condvar, device_xname(self)); | | 240 | cv_init(&sc->sc_condvar, device_xname(self)); |
239 | | | 241 | |
240 | (void)pmf_device_register(self, NULL, acpibat_resume); | | 242 | (void)pmf_device_register(self, NULL, acpibat_resume); |
241 | (void)memset(sc->sc_serial, '\0', sizeof(sc->sc_serial)); | | 243 | (void)memset(sc->sc_serial, '\0', sizeof(sc->sc_serial)); |
242 | (void)acpi_register_notify(sc->sc_node, acpibat_notify_handler); | | 244 | (void)acpi_register_notify(sc->sc_node, acpibat_notify_handler); |
243 | | | 245 | |
244 | sc->sc_sensor = kmem_zalloc(ACPIBAT_COUNT * | | 246 | sc->sc_sensor = kmem_zalloc(ACPIBAT_COUNT * |
245 | sizeof(*sc->sc_sensor), KM_SLEEP); | | 247 | sizeof(*sc->sc_sensor), KM_SLEEP); |
246 | | | 248 | |
247 | if (sc->sc_sensor == NULL) | | 249 | if (sc->sc_sensor == NULL) |
248 | return; | | 250 | return; |
249 | | | 251 | |
250 | acpibat_init_envsys(self); | | 252 | acpibat_init_envsys(self); |
| | | 253 | |
| | | 254 | /* |
| | | 255 | * If this is ever seen, the driver should be extended. |
| | | 256 | */ |
| | | 257 | rv = AcpiGetHandle(sc->sc_node->ad_handle, "_BIX", &tmp); |
| | | 258 | |
| | | 259 | if (ACPI_SUCCESS(rv)) |
| | | 260 | aprint_verbose_dev(self, "ACPI 4.0 functionality present\n"); |
251 | } | | 261 | } |
252 | | | 262 | |
253 | /* | | 263 | /* |
254 | * acpibat_detach: | | 264 | * acpibat_detach: |
255 | * | | 265 | * |
256 | * Autoconfiguration `detach' routine. | | 266 | * Autoconfiguration `detach' routine. |
257 | */ | | 267 | */ |
258 | static int | | 268 | static int |
259 | acpibat_detach(device_t self, int flags) | | 269 | acpibat_detach(device_t self, int flags) |
260 | { | | 270 | { |
261 | struct acpibat_softc *sc = device_private(self); | | 271 | struct acpibat_softc *sc = device_private(self); |
262 | | | 272 | |
263 | acpi_deregister_notify(sc->sc_node); | | 273 | acpi_deregister_notify(sc->sc_node); |