fcu.c revision 222458
1/*- 2 * Copyright (c) 2010 Andreas Tobler 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 21 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> 28__FBSDID("$FreeBSD: head/sys/powerpc/powermac/fcu.c 222458 2011-05-29 18:35:57Z nwhitehorn $"); 29 30#include <sys/param.h> 31#include <sys/bus.h> 32#include <sys/systm.h> 33#include <sys/module.h> 34#include <sys/callout.h> 35#include <sys/conf.h> 36#include <sys/cpu.h> 37#include <sys/ctype.h> 38#include <sys/kernel.h> 39#include <sys/reboot.h> 40#include <sys/rman.h> 41#include <sys/sysctl.h> 42#include <sys/limits.h> 43 44#include <machine/bus.h> 45#include <machine/md_var.h> 46 47#include <dev/iicbus/iicbus.h> 48#include <dev/iicbus/iiconf.h> 49 50#include <dev/ofw/openfirm.h> 51#include <dev/ofw/ofw_bus.h> 52#include <powerpc/powermac/powermac_thermal.h> 53 54/* FCU registers 55 * /u3@0,f8000000/i2c@f8001000/fan@15e 56 */ 57#define FCU_RPM_FAIL 0x0b /* fans states in bits 0<1-6>7 */ 58#define FCU_RPM_AVAILABLE 0x0c 59#define FCU_RPM_ACTIVE 0x0d 60#define FCU_RPM_READ(x) 0x11 + (x) * 2 61#define FCU_RPM_SET(x) 0x10 + (x) * 2 62 63#define FCU_PWM_FAIL 0x2b 64#define FCU_PWM_AVAILABLE 0x2c 65#define FCU_PWM_ACTIVE 0x2d 66#define FCU_PWM_RPM(x) 0x31 + (x) * 2 /* Get RPM. */ 67#define FCU_PWM_SGET(x) 0x30 + (x) * 2 /* Set or get PWM. */ 68 69struct fcu_fan { 70 struct pmac_fan fan; 71 device_t dev; 72 73 int id; 74 enum { 75 FCU_FAN_RPM, 76 FCU_FAN_PWM 77 } type; 78 int setpoint; 79 int rpm; 80}; 81 82struct fcu_softc { 83 device_t sc_dev; 84 struct intr_config_hook enum_hook; 85 uint32_t sc_addr; 86 struct fcu_fan *sc_fans; 87 int sc_nfans; 88}; 89 90/* We can read the PWM and the RPM from a PWM controlled fan. 91 * Offer both values via sysctl. 92 */ 93enum { 94 FCU_PWM_SYSCTL_PWM = 1 << 8, 95 FCU_PWM_SYSCTL_RPM = 2 << 8 96}; 97 98static int fcu_rpm_shift; 99 100/* Regular bus attachment functions */ 101static int fcu_probe(device_t); 102static int fcu_attach(device_t); 103 104/* Utility functions */ 105static void fcu_attach_fans(device_t dev); 106static int fcu_fill_fan_prop(device_t dev); 107static int fcu_fan_set_rpm(struct fcu_fan *fan, int rpm); 108static int fcu_fan_get_rpm(struct fcu_fan *fan); 109static int fcu_fan_set_pwm(struct fcu_fan *fan, int pwm); 110static int fcu_fan_get_pwm(device_t dev, struct fcu_fan *fan, int *pwm, 111 int *rpm); 112static int fcu_fanrpm_sysctl(SYSCTL_HANDLER_ARGS); 113static void fcu_start(void *xdev); 114static int fcu_write(device_t dev, uint32_t addr, uint8_t reg, uint8_t *buf, 115 int len); 116static int fcu_read_1(device_t dev, uint32_t addr, uint8_t reg, uint8_t *data); 117 118static device_method_t fcu_methods[] = { 119 /* Device interface */ 120 DEVMETHOD(device_probe, fcu_probe), 121 DEVMETHOD(device_attach, fcu_attach), 122 { 0, 0 }, 123}; 124 125static driver_t fcu_driver = { 126 "fcu", 127 fcu_methods, 128 sizeof(struct fcu_softc) 129}; 130 131static devclass_t fcu_devclass; 132 133DRIVER_MODULE(fcu, iicbus, fcu_driver, fcu_devclass, 0, 0); 134MALLOC_DEFINE(M_FCU, "fcu", "FCU Sensor Information"); 135 136static int 137fcu_write(device_t dev, uint32_t addr, uint8_t reg, uint8_t *buff, 138 int len) 139{ 140 unsigned char buf[4]; 141 struct iic_msg msg[] = { 142 { addr, IIC_M_WR, 0, buf } 143 }; 144 145 msg[0].len = len + 1; 146 buf[0] = reg; 147 memcpy(buf + 1, buff, len); 148 if (iicbus_transfer(dev, msg, 1) != 0) { 149 device_printf(dev, "iicbus write failed\n"); 150 return (EIO); 151 } 152 153 return (0); 154 155} 156 157static int 158fcu_read_1(device_t dev, uint32_t addr, uint8_t reg, uint8_t *data) 159{ 160 uint8_t buf[4]; 161 162 struct iic_msg msg[2] = { 163 { addr, IIC_M_WR | IIC_M_NOSTOP, 1, ® }, 164 { addr, IIC_M_RD, 1, buf }, 165 }; 166 167 if (iicbus_transfer(dev, msg, 2) != 0) { 168 device_printf(dev, "iicbus read failed\n"); 169 return (EIO); 170 } 171 172 *data = *((uint8_t*)buf); 173 174 return (0); 175} 176 177static int 178fcu_probe(device_t dev) 179{ 180 const char *name, *compatible; 181 struct fcu_softc *sc; 182 183 name = ofw_bus_get_name(dev); 184 compatible = ofw_bus_get_compat(dev); 185 186 if (!name) 187 return (ENXIO); 188 189 if (strcmp(name, "fan") != 0 || strcmp(compatible, "fcu") != 0) 190 return (ENXIO); 191 192 sc = device_get_softc(dev); 193 sc->sc_dev = dev; 194 sc->sc_addr = iicbus_get_addr(dev); 195 196 device_set_desc(dev, "Apple Fan Control Unit"); 197 198 return (0); 199} 200 201static int 202fcu_attach(device_t dev) 203{ 204 struct fcu_softc *sc; 205 206 sc = device_get_softc(dev); 207 208 sc->enum_hook.ich_func = fcu_start; 209 sc->enum_hook.ich_arg = dev; 210 211 /* We have to wait until interrupts are enabled. I2C read and write 212 * only works if the interrupts are available. 213 * The unin/i2c is controlled by the htpic on unin. But this is not 214 * the master. The openpic on mac-io is controlling the htpic. 215 * This one gets attached after the mac-io probing and then the 216 * interrupts will be available. 217 */ 218 219 if (config_intrhook_establish(&sc->enum_hook) != 0) 220 return (ENOMEM); 221 222 return (0); 223} 224 225static void 226fcu_start(void *xdev) 227{ 228 unsigned char buf[1] = { 0xff }; 229 struct fcu_softc *sc; 230 231 device_t dev = (device_t)xdev; 232 233 sc = device_get_softc(dev); 234 235 /* Start the fcu device. */ 236 fcu_write(sc->sc_dev, sc->sc_addr, 0xe, buf, 1); 237 fcu_write(sc->sc_dev, sc->sc_addr, 0x2e, buf, 1); 238 fcu_read_1(sc->sc_dev, sc->sc_addr, 0, buf); 239 fcu_rpm_shift = (buf[0] == 1) ? 2 : 3; 240 241 device_printf(dev, "FCU initialized, RPM shift: %d\n", 242 fcu_rpm_shift); 243 244 /* Detect and attach child devices. */ 245 246 fcu_attach_fans(dev); 247 248 config_intrhook_disestablish(&sc->enum_hook); 249 250} 251 252static int 253fcu_fan_set_rpm(struct fcu_fan *fan, int rpm) 254{ 255 uint8_t reg; 256 struct fcu_softc *sc; 257 unsigned char buf[2]; 258 259 sc = device_get_softc(fan->dev); 260 261 /* Clamp to allowed range */ 262 rpm = max(fan->fan.min_rpm, rpm); 263 rpm = min(fan->fan.max_rpm, rpm); 264 265 if (fan->type == FCU_FAN_RPM) { 266 reg = FCU_RPM_SET(fan->id); 267 fan->setpoint = rpm; 268 } else { 269 device_printf(fan->dev, "Unknown fan type: %d\n", fan->type); 270 return (EIO); 271 } 272 273 buf[0] = rpm >> (8 - fcu_rpm_shift); 274 buf[1] = rpm << fcu_rpm_shift; 275 276 fcu_write(sc->sc_dev, sc->sc_addr, reg, buf, 2); 277 278 return (0); 279} 280 281static int 282fcu_fan_get_rpm(struct fcu_fan *fan) 283{ 284 uint8_t reg; 285 struct fcu_softc *sc; 286 uint8_t buff[2] = { 0, 0 }; 287 uint8_t active = 0, avail = 0, fail = 0; 288 int rpm; 289 290 sc = device_get_softc(fan->dev); 291 292 if (fan->type == FCU_FAN_RPM) { 293 /* Check if the fan is available. */ 294 reg = FCU_RPM_AVAILABLE; 295 fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &avail); 296 if ((avail & (1 << fan->id)) == 0) { 297 device_printf(fan->dev, 298 "RPM Fan not available ID: %d\n", fan->id); 299 return (-1); 300 } 301 /* Check if we have a failed fan. */ 302 reg = FCU_RPM_FAIL; 303 fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &fail); 304 if ((fail & (1 << fan->id)) != 0) { 305 device_printf(fan->dev, 306 "RPM Fan failed ID: %d\n", fan->id); 307 return (-1); 308 } 309 /* Check if fan is active. */ 310 reg = FCU_RPM_ACTIVE; 311 fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &active); 312 if ((active & (1 << fan->id)) == 0) { 313 device_printf(fan->dev, "RPM Fan not active ID: %d\n", 314 fan->id); 315 return (-1); 316 } 317 reg = FCU_RPM_READ(fan->id); 318 319 } else { 320 device_printf(fan->dev, "Unknown fan type: %d\n", fan->type); 321 return (-1); 322 } 323 324 /* It seems that we can read the fans rpm. */ 325 fcu_read_1(sc->sc_dev, sc->sc_addr, reg, buff); 326 327 rpm = (buff[0] << (8 - fcu_rpm_shift)) | buff[1] >> fcu_rpm_shift; 328 329 return (rpm); 330} 331 332static int 333fcu_fan_set_pwm(struct fcu_fan *fan, int pwm) 334{ 335 uint8_t reg; 336 struct fcu_softc *sc; 337 uint8_t buf[2]; 338 339 sc = device_get_softc(fan->dev); 340 341 /* Clamp to allowed range */ 342 pwm = max(fan->fan.min_rpm, pwm); 343 pwm = min(fan->fan.max_rpm, pwm); 344 345 if (fan->type == FCU_FAN_PWM) { 346 reg = FCU_PWM_SGET(fan->id); 347 if (pwm > 100) 348 pwm = 100; 349 if (pwm < 30) 350 pwm = 30; 351 fan->setpoint = pwm; 352 } else { 353 device_printf(fan->dev, "Unknown fan type: %d\n", fan->type); 354 return (EIO); 355 } 356 357 buf[0] = (pwm * 2550) / 1000; 358 359 fcu_write(sc->sc_dev, sc->sc_addr, reg, buf, 1); 360 361 return (0); 362} 363 364static int 365fcu_fan_get_pwm(device_t dev, struct fcu_fan *fan, int *pwm, int *rpm) 366{ 367 uint8_t reg; 368 struct fcu_softc *sc; 369 uint8_t buf[2]; 370 uint8_t active = 0, avail = 0, fail = 0; 371 372 sc = device_get_softc(dev); 373 374 if (fan->type == FCU_FAN_PWM) { 375 /* Check if the fan is available. */ 376 reg = FCU_PWM_AVAILABLE; 377 fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &avail); 378 if ((avail & (1 << fan->id)) == 0) { 379 device_printf(dev, "PWM Fan not available ID: %d\n", 380 fan->id); 381 return (EIO); 382 } 383 /* Check if we have a failed fan. */ 384 reg = FCU_PWM_FAIL; 385 fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &fail); 386 if ((fail & (1 << fan->id)) != 0) { 387 device_printf(dev, "PWM Fan failed ID: %d\n", fan->id); 388 return (EIO); 389 } 390 /* Check if fan is active. */ 391 reg = FCU_PWM_ACTIVE; 392 fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &active); 393 if ((active & (1 << fan->id)) == 0) { 394 device_printf(dev, "PWM Fan not active ID: %d\n", 395 fan->id); 396 return (ENXIO); 397 } 398 reg = FCU_PWM_SGET(fan->id); 399 } else { 400 device_printf(dev, "Unknown fan type: %d\n", fan->type); 401 return (EIO); 402 } 403 404 /* It seems that we can read the fans pwm. */ 405 fcu_read_1(sc->sc_dev, sc->sc_addr, reg, buf); 406 407 *pwm = (buf[0] * 1000) / 2550; 408 409 /* Now read the rpm. */ 410 reg = FCU_PWM_RPM(fan->id); 411 fcu_read_1(sc->sc_dev, sc->sc_addr, reg, buf); 412 *rpm = (buf[0] << (8 - fcu_rpm_shift)) | buf[1] >> fcu_rpm_shift; 413 414 return (0); 415} 416 417/* 418 * This function returns the number of fans. If we call it the second time 419 * and we have allocated memory for sc->sc_fans, we fill in the properties. 420 */ 421static int 422fcu_fill_fan_prop(device_t dev) 423{ 424 phandle_t child; 425 struct fcu_softc *sc; 426 u_int id[8]; 427 char location[96]; 428 char type[64]; 429 int i = 0, j, len = 0, prop_len, prev_len = 0; 430 431 sc = device_get_softc(dev); 432 433 child = ofw_bus_get_node(dev); 434 435 /* Fill the fan location property. */ 436 prop_len = OF_getprop(child, "hwctrl-location", location, 437 sizeof(location)); 438 while (len < prop_len) { 439 if (sc->sc_fans != NULL) { 440 strcpy(sc->sc_fans[i].fan.name, location + len); 441 } 442 prev_len = strlen(location + len) + 1; 443 len += prev_len; 444 i++; 445 } 446 if (sc->sc_fans == NULL) 447 return (i); 448 449 /* Fill the fan type property. */ 450 len = 0; 451 i = 0; 452 prev_len = 0; 453 prop_len = OF_getprop(child, "hwctrl-type", type, sizeof(type)); 454 while (len < prop_len) { 455 if (strcmp(type + len, "fan-rpm") == 0) 456 sc->sc_fans[i].type = FCU_FAN_RPM; 457 else 458 sc->sc_fans[i].type = FCU_FAN_PWM; 459 prev_len = strlen(type + len) + 1; 460 len += prev_len; 461 i++; 462 } 463 464 /* Fill the fan ID property. */ 465 prop_len = OF_getprop(child, "hwctrl-id", id, sizeof(id)); 466 for (j = 0; j < i; j++) 467 sc->sc_fans[j].id = ((id[j] >> 8) & 0x0f) % 8; 468 469 /* Fill the fan zone property. */ 470 prop_len = OF_getprop(child, "hwctrl-zone", id, sizeof(id)); 471 for (j = 0; j < i; j++) 472 sc->sc_fans[j].fan.zone = id[j]; 473 474 /* Finish setting up fan properties */ 475 for (j = 0; j < i; j++) { 476 sc->sc_fans[j].dev = sc->sc_dev; 477 if (sc->sc_fans[j].type == FCU_FAN_RPM) { 478 sc->sc_fans[j].fan.min_rpm = 4800 >> fcu_rpm_shift; 479 sc->sc_fans[j].fan.max_rpm = 56000 >> fcu_rpm_shift; 480 sc->sc_fans[j].setpoint = 481 fcu_fan_get_rpm(&sc->sc_fans[j]); 482 sc->sc_fans[j].fan.read = 483 (int (*)(struct pmac_fan *))(fcu_fan_get_rpm); 484 sc->sc_fans[j].fan.set = 485 (int (*)(struct pmac_fan *, int))(fcu_fan_set_rpm); 486 } else { 487 sc->sc_fans[j].fan.min_rpm = 40; /* Percent */ 488 sc->sc_fans[j].fan.max_rpm = 100; 489 sc->sc_fans[j].fan.read = NULL; 490 sc->sc_fans[j].fan.set = 491 (int (*)(struct pmac_fan *, int))(fcu_fan_set_pwm); 492 } 493 sc->sc_fans[j].fan.default_rpm = sc->sc_fans[j].fan.max_rpm; 494 } 495 496 return (i); 497} 498 499static int 500fcu_fanrpm_sysctl(SYSCTL_HANDLER_ARGS) 501{ 502 device_t fcu; 503 struct fcu_softc *sc; 504 struct fcu_fan *fan; 505 int rpm = 0, pwm = 0, error; 506 507 fcu = arg1; 508 sc = device_get_softc(fcu); 509 fan = &sc->sc_fans[arg2 & 0x00ff]; 510 if (fan->type == FCU_FAN_RPM) { 511 rpm = fcu_fan_get_rpm(fan); 512 error = sysctl_handle_int(oidp, &rpm, 0, req); 513 } else { 514 fcu_fan_get_pwm(fcu, fan, &pwm, &rpm); 515 516 switch (arg2 & 0xff00) { 517 case FCU_PWM_SYSCTL_PWM: 518 error = sysctl_handle_int(oidp, &pwm, 0, req); 519 break; 520 case FCU_PWM_SYSCTL_RPM: 521 error = sysctl_handle_int(oidp, &rpm, 0, req); 522 break; 523 default: 524 /* This should never happen */ 525 error = -1; 526 }; 527 } 528 529 /* We can only read the RPM from a PWM controlled fan, so return. */ 530 if ((arg2 & 0xff00) == FCU_PWM_SYSCTL_RPM) 531 return (0); 532 533 if (error || !req->newptr) 534 return (error); 535 536 if (fan->type == FCU_FAN_RPM) 537 return (fcu_fan_set_rpm(fan, rpm)); 538 else 539 return (fcu_fan_set_pwm(fan, pwm)); 540} 541 542static void 543fcu_attach_fans(device_t dev) 544{ 545 struct fcu_softc *sc; 546 struct sysctl_oid *oid, *fanroot_oid; 547 struct sysctl_ctx_list *ctx; 548 char sysctl_name[32]; 549 int i, j; 550 551 sc = device_get_softc(dev); 552 553 sc->sc_nfans = 0; 554 555 /* Count the actual number of fans. */ 556 sc->sc_nfans = fcu_fill_fan_prop(dev); 557 558 device_printf(dev, "%d fans detected!\n", sc->sc_nfans); 559 560 if (sc->sc_nfans == 0) { 561 device_printf(dev, "WARNING: No fans detected!\n"); 562 return; 563 } 564 565 sc->sc_fans = malloc(sc->sc_nfans * sizeof(struct fcu_fan), M_FCU, 566 M_WAITOK | M_ZERO); 567 568 ctx = device_get_sysctl_ctx(dev); 569 fanroot_oid = SYSCTL_ADD_NODE(ctx, 570 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "fans", 571 CTLFLAG_RD, 0, "FCU Fan Information"); 572 573 /* Now we can fill the properties into the allocated struct. */ 574 sc->sc_nfans = fcu_fill_fan_prop(dev); 575 576 /* Register fans with pmac_thermal */ 577 for (i = 0; i < sc->sc_nfans; i++) 578 pmac_thermal_fan_register(&sc->sc_fans[i].fan); 579 580 /* Add sysctls for the fans. */ 581 for (i = 0; i < sc->sc_nfans; i++) { 582 for (j = 0; j < strlen(sc->sc_fans[i].fan.name); j++) { 583 sysctl_name[j] = tolower(sc->sc_fans[i].fan.name[j]); 584 if (isspace(sysctl_name[j])) 585 sysctl_name[j] = '_'; 586 } 587 sysctl_name[j] = 0; 588 589 if (sc->sc_fans[i].type == FCU_FAN_RPM) { 590 oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(fanroot_oid), 591 OID_AUTO, sysctl_name, 592 CTLFLAG_RD, 0, "Fan Information"); 593 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 594 "minrpm", CTLTYPE_INT | CTLFLAG_RD, 595 &(sc->sc_fans[i].fan.min_rpm), 596 sizeof(int), "Minimum allowed RPM"); 597 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 598 "maxrpm", CTLTYPE_INT | CTLFLAG_RD, 599 &(sc->sc_fans[i].fan.max_rpm), 600 sizeof(int), "Maximum allowed RPM"); 601 /* I use i to pass the fan id. */ 602 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 603 "rpm", CTLTYPE_INT | CTLFLAG_RW, dev, i, 604 fcu_fanrpm_sysctl, "I", "Fan RPM"); 605 } else { 606 fcu_fan_get_pwm(dev, &sc->sc_fans[i], 607 &sc->sc_fans[i].setpoint, 608 &sc->sc_fans[i].rpm); 609 610 oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(fanroot_oid), 611 OID_AUTO, sysctl_name, 612 CTLFLAG_RD, 0, "Fan Information"); 613 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 614 "minpwm", CTLTYPE_INT | CTLFLAG_RD, 615 &(sc->sc_fans[i].fan.min_rpm), 616 sizeof(int), "Minimum allowed PWM in %"); 617 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 618 "maxpwm", CTLTYPE_INT | CTLFLAG_RD, 619 &(sc->sc_fans[i].fan.max_rpm), 620 sizeof(int), "Maximum allowed PWM in %"); 621 /* I use i to pass the fan id or'ed with the type 622 * of info I want to display/modify. 623 */ 624 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 625 "pwm", CTLTYPE_INT | CTLFLAG_RW, dev, 626 FCU_PWM_SYSCTL_PWM | i, 627 fcu_fanrpm_sysctl, "I", "Fan PWM in %"); 628 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, 629 "rpm", CTLTYPE_INT | CTLFLAG_RD, dev, 630 FCU_PWM_SYSCTL_RPM | i, 631 fcu_fanrpm_sysctl, "I", "Fan RPM"); 632 } 633 } 634 635 /* Dump fan location, type & RPM. */ 636 if (bootverbose) { 637 device_printf(dev, "Fans\n"); 638 for (i = 0; i < sc->sc_nfans; i++) { 639 device_printf(dev, "Location: %s type: %d ID: %d " 640 "RPM: %d\n", sc->sc_fans[i].fan.name, 641 sc->sc_fans[i].type, sc->sc_fans[i].id, 642 (sc->sc_fans[i].type == FCU_FAN_RPM) ? 643 sc->sc_fans[i].setpoint : 644 sc->sc_fans[i].rpm ); 645 } 646 } 647} 648