| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: acpi_bat.c,v 1.122 2024/04/26 18:19:18 christos Exp $ */ | | 1 | /* $NetBSD: acpi_bat.c,v 1.123 2024/04/27 00:40:06 christos 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.122 2024/04/26 18:19:18 christos Exp $"); | | 78 | __KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.123 2024/04/27 00:40:06 christos 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 | |
| @@ -219,34 +219,26 @@ acpibat_match(device_t parent, cfdata_t | | | @@ -219,34 +219,26 @@ acpibat_match(device_t parent, cfdata_t |
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; | | 224 | ACPI_HANDLE tmp; |
225 | ACPI_STATUS rv; | | 225 | ACPI_STATUS rv; |
226 | | | 226 | |
227 | aprint_naive(": ACPI Battery\n"); | | 227 | aprint_naive(": ACPI Battery\n"); |
228 | aprint_normal(": ACPI Battery\n"); | | 228 | aprint_normal(": ACPI Battery\n"); |
229 | | | 229 | |
230 | sc->sc_node = aa->aa_node; | | 230 | sc->sc_node = aa->aa_node; |
231 | | | 231 | |
232 | sc->sc_present = 0; | | | |
233 | sc->sc_dvoltage = 0; | | | |
234 | sc->sc_dcapacity = 0; | | | |
235 | sc->sc_lcapacity = 0; | | | |
236 | sc->sc_wcapacity = 0; | | | |
237 | | | | |
238 | sc->sc_sme = NULL; | | | |
239 | | | | |
240 | mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_NONE); | | 232 | mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_NONE); |
241 | cv_init(&sc->sc_condvar, device_xname(self)); | | 233 | cv_init(&sc->sc_condvar, device_xname(self)); |
242 | | | 234 | |
243 | sc->sc_sensor = kmem_zalloc(ACPIBAT_COUNT * | | 235 | sc->sc_sensor = kmem_zalloc(ACPIBAT_COUNT * |
244 | sizeof(*sc->sc_sensor), KM_SLEEP); | | 236 | sizeof(*sc->sc_sensor), KM_SLEEP); |
245 | | | 237 | |
246 | config_interrupts(self, acpibat_init_envsys); | | 238 | config_interrupts(self, acpibat_init_envsys); |
247 | | | 239 | |
248 | /* | | 240 | /* |
249 | * If this is ever seen, the driver should be extended. | | 241 | * If this is ever seen, the driver should be extended. |
250 | */ | | 242 | */ |
251 | rv = AcpiGetHandle(sc->sc_node->ad_handle, "_BIX", &tmp); | | 243 | rv = AcpiGetHandle(sc->sc_node->ad_handle, "_BIX", &tmp); |
252 | if (ACPI_SUCCESS(rv)) | | 244 | if (ACPI_SUCCESS(rv)) |
| @@ -749,27 +741,27 @@ acpibat_init_envsys(device_t dv) | | | @@ -749,27 +741,27 @@ acpibat_init_envsys(device_t dv) |
749 | | | 741 | |
750 | sc->sc_sme = sysmon_envsys_create(); | | 742 | sc->sc_sme = sysmon_envsys_create(); |
751 | | | 743 | |
752 | for (i = 0; i < ACPIBAT_COUNT; i++) { | | 744 | for (i = 0; i < ACPIBAT_COUNT; i++) { |
753 | if (sysmon_envsys_sensor_attach(sc->sc_sme, | | 745 | if (sysmon_envsys_sensor_attach(sc->sc_sme, |
754 | &sc->sc_sensor[i])) | | 746 | &sc->sc_sensor[i])) |
755 | goto fail; | | 747 | goto fail; |
756 | } | | 748 | } |
757 | | | 749 | |
758 | sc->sc_sme->sme_name = device_xname(dv); | | 750 | sc->sc_sme->sme_name = device_xname(dv); |
759 | sc->sc_sme->sme_cookie = dv; | | 751 | sc->sc_sme->sme_cookie = dv; |
760 | sc->sc_sme->sme_refresh = acpibat_refresh; | | 752 | sc->sc_sme->sme_refresh = acpibat_refresh; |
761 | sc->sc_sme->sme_class = SME_CLASS_BATTERY; | | 753 | sc->sc_sme->sme_class = SME_CLASS_BATTERY; |
762 | sc->sc_sme->sme_flags = SME_POLL_ONLY | SME_INIT_REFRESH; | | 754 | sc->sc_sme->sme_flags = SME_POLL_ONLY; |
763 | sc->sc_sme->sme_get_limits = acpibat_get_limits; | | 755 | sc->sc_sme->sme_get_limits = acpibat_get_limits; |
764 | | | 756 | |
765 | if (sysmon_envsys_register(sc->sc_sme)) | | 757 | if (sysmon_envsys_register(sc->sc_sme)) |
766 | goto fail; | | 758 | goto fail; |
767 | | | 759 | |
768 | (void)acpi_register_notify(sc->sc_node, acpibat_notify_handler); | | 760 | (void)acpi_register_notify(sc->sc_node, acpibat_notify_handler); |
769 | acpibat_update_info(dv); | | 761 | acpibat_update_info(dv); |
770 | acpibat_update_status(dv); | | 762 | acpibat_update_status(dv); |
771 | | | 763 | |
772 | (void)pmf_device_register(dv, NULL, acpibat_resume); | | 764 | (void)pmf_device_register(dv, NULL, acpibat_resume); |
773 | | | 765 | |
774 | return; | | 766 | return; |
775 | fail: | | 767 | fail: |