1 /* $NetBSD: acpi_tz.c,v 1.19 2006/10/12 01:30:54 christos Exp $ */ 2 3 /* 4 * Copyright (c) 2003 Jared D. McNeill <jmcneill@invisible.ca> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. The name of the author may not be used to endorse or promote products 13 * derived from this software without specific prior written permission. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28 /* 29 * ACPI Thermal Zone driver 30 */ 31 32 #include <sys/cdefs.h> 33 __KERNEL_RCSID(0, "$NetBSD: acpi_tz.c,v 1.19 2006/10/12 01:30:54 christos Exp $"); 34 35 #include <sys/param.h> 36 #include <sys/systm.h> 37 #include <sys/kernel.h> 38 #include <sys/errno.h> 39 #include <sys/ioctl.h> 40 #include <sys/syslog.h> 41 #include <sys/device.h> 42 #include <sys/callout.h> 43 #include <sys/proc.h> 44 #include <sys/lock.h> 45 #include <dev/sysmon/sysmonvar.h> 46 47 #include <dev/acpi/acpica.h> 48 #include <dev/acpi/acpireg.h> 49 #include <dev/acpi/acpivar.h> 50 51 /* flags */ 52 #define ATZ_F_VERBOSE 0x01 /* show events to console */ 53 #define ATZ_F_CRITICAL 0x02 /* zone critical */ 54 #define ATZ_F_HOT 0x04 /* zone hot */ 55 #define ATZ_F_PASSIVE 0x08 /* zone passive cooling */ 56 #define ATZ_F_PASSIVEONLY 0x10 /* zone is passive cooling only */ 57 58 /* no active cooling level */ 59 #define ATZ_ACTIVE_NONE -1 60 61 /* constants */ 62 #define ATZ_TZP_RATE 300 /* default if no _TZP CM present (30 secs) */ 63 #define ATZ_NLEVELS 10 /* number of cooling levels, from ACPI spec */ 64 #define ATZ_ZEROC 2732 /* 0C in tenths degrees Kelvin */ 65 #define ATZ_TMP_INVALID 0xffffffff /* invalid temperature */ 66 #define ATZ_ZONE_EXPIRE 9000 /* zone info refetch interval (15min) */ 67 68 /* sensor indexes */ 69 #define ATZ_SENSOR_TEMP 0 /* thermal zone temperature */ 70 #define ATZ_NUMSENSORS 1 /* number of sensors */ 71 72 static const struct envsys_range acpitz_ranges[] = { 73 { 0, 1, ATZ_SENSOR_TEMP }, 74 }; 75 76 static int acpitz_match(struct device *, struct cfdata *, void *); 77 static void acpitz_attach(struct device *, struct device *, void *); 78 79 /* 80 * ACPI Temperature Zone information. Note all temperatures are reported 81 * in tenths of degrees Kelvin 82 */ 83 struct acpitz_zone { 84 /* Active cooling temperature threshold */ 85 UINT32 ac[ATZ_NLEVELS]; 86 /* Package of references to all active cooling devices for a level */ 87 ACPI_BUFFER al[ATZ_NLEVELS]; 88 /* Critical temperature threshold for system shutdown */ 89 UINT32 crt; 90 /* Critical temperature threshold for S4 sleep */ 91 UINT32 hot; 92 /* Package of references to processor objects for passive cooling */ 93 ACPI_BUFFER psl; 94 /* Passive cooling temperature threshold */ 95 UINT32 psv; 96 /* Thermal constants for use in passive cooling formulas */ 97 UINT32 tc1, tc2; 98 /* Current temperature of the thermal zone */ 99 UINT32 tmp; 100 /* Thermal sampling period for passive cooling, in tenths of seconds */ 101 UINT32 tsp; 102 /* Package of references to devices in this TZ (optional) */ 103 ACPI_BUFFER tzd; 104 /* Recommended TZ polling frequency, in tenths of seconds */ 105 UINT32 tzp; 106 }; 107 108 struct acpitz_softc { 109 struct device sc_dev; 110 struct acpi_devnode *sc_devnode; 111 struct acpitz_zone sc_zone; 112 struct callout sc_callout; 113 struct envsys_tre_data sc_data[ATZ_NUMSENSORS]; 114 struct envsys_basic_info sc_info[ATZ_NUMSENSORS]; 115 struct sysmon_envsys sc_sysmon; 116 struct simplelock sc_slock; 117 int sc_active; /* active cooling level */ 118 int sc_flags; 119 int sc_rate; /* tz poll rate */ 120 int sc_zone_expire; 121 }; 122 123 static void acpitz_get_status(void *); 124 static void acpitz_get_zone(void *, int); 125 static void acpitz_get_zone_quiet(void *); 126 static char* acpitz_celcius_string(int); 127 static void acpitz_print_status(struct acpitz_softc *); 128 static void acpitz_power_off(struct acpitz_softc *); 129 static void acpitz_power_zone(struct acpitz_softc *, int, int); 130 static void acpitz_sane_temp(UINT32 *tmp); 131 static ACPI_STATUS 132 acpitz_switch_cooler(ACPI_OBJECT *, void *); 133 static void acpitz_notify_handler(ACPI_HANDLE, UINT32, void *); 134 static int acpitz_get_integer(struct acpitz_softc *, const char *, UINT32 *); 135 static void acpitz_tick(void *); 136 static void acpitz_init_envsys(struct acpitz_softc *); 137 static int acpitz_gtredata(struct sysmon_envsys *, 138 struct envsys_tre_data *); 139 static int acpitz_streinfo(struct sysmon_envsys *, 140 struct envsys_basic_info *); 141 142 CFATTACH_DECL(acpitz, sizeof(struct acpitz_softc), acpitz_match, 143 acpitz_attach, NULL, NULL); 144 145 /* 146 * acpitz_match: autoconf(9) match routine 147 */ 148 static int 149 acpitz_match(struct device *parent __unused, struct cfdata *match __unused, 150 void *aux) 151 { 152 struct acpi_attach_args *aa = aux; 153 154 if (aa->aa_node->ad_type != ACPI_TYPE_THERMAL) 155 return 0; 156 157 return 1; 158 } 159 160 /* 161 * acpitz_attach: autoconf(9) attach routine 162 */ 163 static void 164 acpitz_attach(struct device *parent __unused, struct device *self, void *aux) 165 { 166 struct acpitz_softc *sc = (struct acpitz_softc *)self; 167 struct acpi_attach_args *aa = aux; 168 ACPI_STATUS rv; 169 ACPI_INTEGER v; 170 171 #if 0 172 sc->sc_flags = ATZ_F_VERBOSE; 173 #endif 174 sc->sc_devnode = aa->aa_node; 175 176 aprint_naive(": ACPI Thermal Zone\n"); 177 aprint_normal(": ACPI Thermal Zone\n"); 178 179 rv = acpi_eval_integer(sc->sc_devnode->ad_handle, "_TZP", &v); 180 if (ACPI_FAILURE(rv)) { 181 aprint_verbose("%s: unable to get polling interval; using default of", 182 sc->sc_dev.dv_xname); 183 sc->sc_zone.tzp = ATZ_TZP_RATE; 184 } else { 185 sc->sc_zone.tzp = v; 186 aprint_verbose("%s: polling interval is", sc->sc_dev.dv_xname); 187 } 188 aprint_verbose(" %d.%ds\n", sc->sc_zone.tzp / 10, sc->sc_zone.tzp % 10); 189 190 /* XXX a value of 0 means "polling is not necessary" */ 191 if (sc->sc_zone.tzp == 0) 192 sc->sc_zone.tzp = ATZ_TZP_RATE; 193 194 sc->sc_zone_expire = ATZ_ZONE_EXPIRE / sc->sc_zone.tzp; 195 196 acpitz_get_zone(sc, 1); 197 acpitz_get_status(sc); 198 199 rv = AcpiInstallNotifyHandler(sc->sc_devnode->ad_handle, 200 ACPI_SYSTEM_NOTIFY, acpitz_notify_handler, sc); 201 if (ACPI_FAILURE(rv)) { 202 aprint_error("%s: unable to install SYSTEM NOTIFY handler: %s\n", 203 sc->sc_dev.dv_xname, AcpiFormatException(rv)); 204 return; 205 } 206 207 callout_init(&sc->sc_callout); 208 callout_reset(&sc->sc_callout, sc->sc_zone.tzp * hz / 10, 209 acpitz_tick, sc); 210 211 acpitz_init_envsys(sc); 212 } 213 214 static void 215 acpitz_get_zone_quiet(void *opaque) 216 { 217 acpitz_get_zone(opaque, 0); 218 } 219 220 static void 221 acpitz_get_status(void *opaque) 222 { 223 struct acpitz_softc *sc = opaque; 224 UINT32 tmp, active; 225 int i, flags; 226 227 sc->sc_zone_expire--; 228 if (sc->sc_zone_expire <= 0) { 229 sc->sc_zone_expire = ATZ_ZONE_EXPIRE / sc->sc_zone.tzp; 230 if (sc->sc_flags & ATZ_F_VERBOSE) 231 printf("%s: force refetch zone\n", sc->sc_dev.dv_xname); 232 acpitz_get_zone(sc, 0); 233 } 234 235 if (acpitz_get_integer(sc, "_TMP", &tmp)) { 236 printf("%s: failed to evaluate _TMP\n", sc->sc_dev.dv_xname); 237 return; 238 } 239 sc->sc_zone.tmp = tmp; 240 /* XXX sanity check for tmp here? */ 241 242 /* 243 * The temperature unit for envsys(4) is microKelvin, so convert to 244 * that from ACPI's microKelvin. Also, the ACPI specification assumes 245 * that K = C + 273.2 rather than the nominal 273.15 used by envsys(4), 246 * so we correct for that too. 247 */ 248 sc->sc_data[ATZ_SENSOR_TEMP].cur.data_us = 249 sc->sc_zone.tmp * 100000 - 50000; 250 sc->sc_data[ATZ_SENSOR_TEMP].validflags |= ENVSYS_FCURVALID; 251 252 if (sc->sc_flags & ATZ_F_VERBOSE) 253 acpitz_print_status(sc); 254 255 if (sc->sc_flags & ATZ_F_PASSIVEONLY) { 256 /* Passive Cooling: XXX not yet */ 257 258 } else { 259 /* Active Cooling */ 260 261 /* temperature threshold: _AC0 > ... > _AC9 */ 262 active = ATZ_ACTIVE_NONE; 263 for (i = ATZ_NLEVELS - 1; i >= 0; i--) { 264 if (sc->sc_zone.ac[i] == ATZ_TMP_INVALID) 265 continue; 266 267 /* we want to keep highest cooling mode in 'active' */ 268 if (sc->sc_zone.ac[i] <= tmp) 269 active = i; 270 } 271 272 flags = sc->sc_flags & ~(ATZ_F_CRITICAL|ATZ_F_HOT|ATZ_F_PASSIVE); 273 if (sc->sc_zone.psv != ATZ_TMP_INVALID && 274 tmp >= sc->sc_zone.psv) 275 flags |= ATZ_F_PASSIVE; 276 if (sc->sc_zone.hot != ATZ_TMP_INVALID && 277 tmp >= sc->sc_zone.hot) 278 flags |= ATZ_F_HOT; 279 if (sc->sc_zone.crt != ATZ_TMP_INVALID && 280 tmp >= sc->sc_zone.crt) 281 flags |= ATZ_F_CRITICAL; 282 283 if (flags != sc->sc_flags) { 284 int changed = (sc->sc_flags ^ flags) & flags; 285 sc->sc_flags = flags; 286 if (changed & ATZ_F_CRITICAL) 287 printf("%s: zone went critical at temp %sC\n", 288 sc->sc_dev.dv_xname, 289 acpitz_celcius_string(tmp)); 290 else if (changed & ATZ_F_HOT) 291 printf("%s: zone went hot at temp %sC\n", 292 sc->sc_dev.dv_xname, 293 acpitz_celcius_string(tmp)); 294 } 295 296 /* power on fans */ 297 if (sc->sc_active != active) { 298 if (sc->sc_active != ATZ_ACTIVE_NONE) 299 acpitz_power_zone(sc, sc->sc_active, 0); 300 301 if (active != ATZ_ACTIVE_NONE) { 302 if (sc->sc_flags & ATZ_F_VERBOSE) 303 printf("%s: active cooling level %u\n", 304 sc->sc_dev.dv_xname, active); 305 acpitz_power_zone(sc, active, 1); 306 } 307 308 sc->sc_active = active; 309 } 310 } 311 312 return; 313 } 314 315 static char * 316 acpitz_celcius_string(int dk) 317 { 318 static char buf[10]; 319 320 snprintf(buf, sizeof(buf), "%d.%d", (dk - ATZ_ZEROC) / 10, 321 (dk - ATZ_ZEROC) % 10); 322 323 return buf; 324 } 325 326 static void 327 acpitz_print_status(struct acpitz_softc *sc) 328 { 329 330 printf("%s: zone temperature is now %sC\n", sc->sc_dev.dv_xname, 331 acpitz_celcius_string(sc->sc_zone.tmp)); 332 333 return; 334 } 335 336 static ACPI_STATUS 337 acpitz_switch_cooler(ACPI_OBJECT *obj, void *arg) 338 { 339 ACPI_HANDLE cooler; 340 ACPI_STATUS rv; 341 int pwr_state, flag; 342 343 flag = *(int *)arg; 344 345 if (flag) 346 pwr_state = ACPI_STATE_D0; 347 else 348 pwr_state = ACPI_STATE_D3; 349 350 switch(obj->Type) { 351 case ACPI_TYPE_ANY: 352 cooler = obj->Reference.Handle; 353 break; 354 case ACPI_TYPE_STRING: 355 rv = AcpiGetHandle(NULL, obj->String.Pointer, &cooler); 356 if (ACPI_FAILURE(rv)) { 357 printf("failed to get handler from %s\n", 358 obj->String.Pointer); 359 return rv; 360 } 361 break; 362 default: 363 printf("unknown power type: %d\n", obj->Type); 364 return AE_OK; 365 } 366 367 rv = acpi_pwr_switch_consumer(cooler, pwr_state); 368 if (rv != AE_BAD_PARAMETER && ACPI_FAILURE(rv)) { 369 printf("failed to change state for %s: %s\n", 370 acpi_name(obj->Reference.Handle), 371 AcpiFormatException(rv)); 372 } 373 374 return AE_OK; 375 } 376 377 /* 378 * acpitz_power_zone: 379 * power on or off the i:th part of the zone zone 380 */ 381 static void 382 acpitz_power_zone(struct acpitz_softc *sc, int i, int on) 383 { 384 KASSERT(i >= 0 && i < ATZ_NLEVELS); 385 386 acpi_foreach_package_object(sc->sc_zone.al[i].Pointer, 387 acpitz_switch_cooler, &on); 388 } 389 390 391 /* 392 * acpitz_power_off: 393 * power off parts of the zone 394 */ 395 static void 396 acpitz_power_off(struct acpitz_softc *sc) 397 { 398 int i; 399 400 for (i = 0 ; i < ATZ_NLEVELS; i++) { 401 if (sc->sc_zone.al[i].Pointer == NULL) 402 continue; 403 acpitz_power_zone(sc, i, 0); 404 } 405 sc->sc_active = ATZ_ACTIVE_NONE; 406 sc->sc_flags &= ~(ATZ_F_CRITICAL|ATZ_F_HOT|ATZ_F_PASSIVE); 407 } 408 409 static void 410 acpitz_get_zone(void *opaque, int verbose) 411 { 412 struct acpitz_softc *sc = opaque; 413 ACPI_STATUS rv; 414 char buf[8]; 415 int i, valid_levels; 416 static int first = 1; 417 418 if (!first) { 419 acpitz_power_off(sc); 420 421 for (i = 0; i < ATZ_NLEVELS; i++) { 422 if (sc->sc_zone.al[i].Pointer != NULL) 423 AcpiOsFree(sc->sc_zone.al[i].Pointer); 424 sc->sc_zone.al[i].Pointer = NULL; 425 } 426 } 427 428 valid_levels = 0; 429 430 for (i = 0; i < ATZ_NLEVELS; i++) { 431 ACPI_OBJECT *obj; 432 433 snprintf(buf, sizeof(buf), "_AC%d", i); 434 if (acpitz_get_integer(sc, buf, &sc->sc_zone.ac[i])) 435 continue; 436 437 snprintf(buf, sizeof(buf), "_AL%d", i); 438 rv = acpi_eval_struct(sc->sc_devnode->ad_handle, buf, 439 &sc->sc_zone.al[i]); 440 if (ACPI_FAILURE(rv)) { 441 printf("failed getting _AL%d", i); 442 sc->sc_zone.al[i].Pointer = NULL; 443 continue; 444 } 445 446 obj = sc->sc_zone.al[i].Pointer; 447 if (obj != NULL) { 448 if (obj->Type != ACPI_TYPE_PACKAGE) { 449 printf("%s: ac%d not package\n", 450 sc->sc_dev.dv_xname, i); 451 AcpiOsFree(obj); 452 sc->sc_zone.al[i].Pointer = NULL; 453 continue; 454 } 455 } 456 457 if (first) 458 printf("%s: active cooling level %d: %sC\n", 459 sc->sc_dev.dv_xname, i, 460 acpitz_celcius_string(sc->sc_zone.ac[i])); 461 462 valid_levels++; 463 } 464 465 if (valid_levels == 0) { 466 sc->sc_flags |= ATZ_F_PASSIVEONLY; 467 if (first) 468 printf("%s: passive cooling mode only\n", 469 sc->sc_dev.dv_xname); 470 } 471 472 acpitz_get_integer(sc, "_TMP", &sc->sc_zone.tmp); 473 acpitz_get_integer(sc, "_CRT", &sc->sc_zone.crt); 474 acpitz_get_integer(sc, "_HOT", &sc->sc_zone.hot); 475 sc->sc_zone.psl.Length = ACPI_ALLOCATE_BUFFER; 476 sc->sc_zone.psl.Pointer = NULL; 477 AcpiEvaluateObject(sc, "_PSL", NULL, &sc->sc_zone.psl); 478 acpitz_get_integer(sc, "_PSV", &sc->sc_zone.psv); 479 acpitz_get_integer(sc, "_TC1", &sc->sc_zone.tc1); 480 acpitz_get_integer(sc, "_TC2", &sc->sc_zone.tc2); 481 482 acpitz_sane_temp(&sc->sc_zone.tmp); 483 acpitz_sane_temp(&sc->sc_zone.crt); 484 acpitz_sane_temp(&sc->sc_zone.hot); 485 acpitz_sane_temp(&sc->sc_zone.psv); 486 487 if (verbose) { 488 printf("%s:", sc->sc_dev.dv_xname); 489 if (sc->sc_zone.crt != ATZ_TMP_INVALID) 490 printf(" critical %sC", 491 acpitz_celcius_string(sc->sc_zone.crt)); 492 if (sc->sc_zone.hot != ATZ_TMP_INVALID) 493 printf(" hot %sC", 494 acpitz_celcius_string(sc->sc_zone.hot)); 495 if (sc->sc_zone.psv != ATZ_TMP_INVALID) 496 printf(" passive %sC", 497 acpitz_celcius_string(sc->sc_zone.tmp)); 498 printf("\n"); 499 } 500 501 for (i = 0; i < ATZ_NLEVELS; i++) 502 acpitz_sane_temp(&sc->sc_zone.ac[i]); 503 504 acpitz_power_off(sc); 505 first = 0; 506 } 507 508 509 static void 510 acpitz_notify_handler(ACPI_HANDLE hdl __unused, UINT32 notify, void *opaque) 511 { 512 struct acpitz_softc *sc = opaque; 513 ACPI_OSD_EXEC_CALLBACK func = NULL; 514 const char *name; 515 int rv; 516 517 switch (notify) { 518 case ACPI_NOTIFY_ThermalZoneStatusChanged: 519 func = acpitz_get_status; 520 name = "status check"; 521 break; 522 case ACPI_NOTIFY_ThermalZoneTripPointsChanged: 523 case ACPI_NOTIFY_DeviceListsChanged: 524 func = acpitz_get_zone_quiet; 525 name = "get zone"; 526 break; 527 default: 528 printf("%s: received unhandled notify message 0x%x\n", 529 sc->sc_dev.dv_xname, notify); 530 return; 531 } 532 533 KASSERT(func != NULL); 534 535 rv = AcpiOsQueueForExecution(OSD_PRIORITY_LO, func, sc); 536 if (rv != AE_OK) 537 printf("%s: unable to queue %s\n", sc->sc_dev.dv_xname, name); 538 539 return; 540 } 541 542 static void 543 acpitz_sane_temp(UINT32 *tmp) 544 { 545 /* Sane temperatures are beteen 0 and 150 C */ 546 if (*tmp < ATZ_ZEROC || *tmp > ATZ_ZEROC + 1500) 547 *tmp = ATZ_TMP_INVALID; 548 } 549 550 static int 551 acpitz_get_integer(struct acpitz_softc *sc, const char *cm, UINT32 *val) 552 { 553 ACPI_STATUS rv; 554 ACPI_INTEGER tmp; 555 556 rv = acpi_eval_integer(sc->sc_devnode->ad_handle, cm, &tmp); 557 if (ACPI_FAILURE(rv)) { 558 #ifdef ACPI_DEBUG 559 printf("%s: failed to evaluate %s: %s\n", sc->sc_dev.dv_xname, 560 cm, AcpiFormatException(rv)); 561 #endif 562 *val = ATZ_TMP_INVALID; 563 return 1; 564 } 565 566 *val = tmp; 567 568 return 0; 569 } 570 571 static void 572 acpitz_tick(void *opaque) 573 { 574 struct acpitz_softc *sc = opaque; 575 576 callout_reset(&sc->sc_callout, sc->sc_zone.tzp * hz / 10, 577 acpitz_tick, opaque); 578 AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpitz_get_status, sc); 579 580 return; 581 } 582 583 static void 584 acpitz_init_envsys(struct acpitz_softc *sc) 585 { 586 int i; 587 588 simple_lock_init(&sc->sc_slock); 589 590 for (i = 0; i < ATZ_NUMSENSORS; i++) { 591 sc->sc_data[i].sensor = sc->sc_info[i].sensor = i; 592 sc->sc_data[i].validflags = ENVSYS_FVALID; 593 sc->sc_info[i].validflags = ENVSYS_FVALID; 594 sc->sc_data[i].warnflags = ENVSYS_WARN_OK; 595 } 596 #define INITDATA(index, unit, string) \ 597 sc->sc_data[index].units = unit; \ 598 sc->sc_info[index].units = unit; \ 599 snprintf(sc->sc_info[index].desc, sizeof(sc->sc_info[index].desc), \ 600 "%s %s", sc->sc_dev.dv_xname, string); 601 602 INITDATA(ATZ_SENSOR_TEMP, ENVSYS_STEMP, "temperature"); 603 604 /* hook into sysmon */ 605 sc->sc_sysmon.sme_ranges = acpitz_ranges; 606 sc->sc_sysmon.sme_sensor_info = sc->sc_info; 607 sc->sc_sysmon.sme_sensor_data = sc->sc_data; 608 sc->sc_sysmon.sme_cookie = sc; 609 sc->sc_sysmon.sme_gtredata = acpitz_gtredata; 610 sc->sc_sysmon.sme_streinfo = acpitz_streinfo; 611 sc->sc_sysmon.sme_nsensors = ATZ_NUMSENSORS; 612 sc->sc_sysmon.sme_envsys_version = 1000; 613 614 if (sysmon_envsys_register(&sc->sc_sysmon)) 615 printf("%s: unable to register with sysmon\n", 616 sc->sc_dev.dv_xname); 617 } 618 619 int 620 acpitz_gtredata(struct sysmon_envsys *sme, struct envsys_tre_data *tred) 621 { 622 struct acpitz_softc *sc = sme->sme_cookie; 623 624 simple_lock(&sc->sc_slock); 625 626 *tred = sc->sc_data[tred->sensor]; 627 628 simple_unlock(&sc->sc_slock); 629 630 return 0; 631 } 632 633 static int 634 acpitz_streinfo(struct sysmon_envsys *sme __unused, 635 struct envsys_basic_info *binfo) 636 { 637 638 /* XXX not implemented */ 639 binfo->validflags = 0; 640 641 return 0; 642 } 643