Lines Matching +full:fan +full:- +full:speed
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
78 static int asmc_fan_getvalue(device_t dev, const char *key, int fan);
79 static int asmc_fan_setvalue(device_t dev, const char *key, int fan, int speed);
186 "MacBookPro1,1", "Apple SMC MacBook Pro Core Duo (15-inch)",
192 "MacBookPro1,2", "Apple SMC MacBook Pro Core Duo (17-inch)",
198 "MacBookPro2,1", "Apple SMC MacBook Pro Core 2 Duo (17-inch)",
204 "MacBookPro2,2", "Apple SMC MacBook Pro Core 2 Duo (15-inch)",
210 "MacBookPro3,1", "Apple SMC MacBook Pro Core 2 Duo (15-inch LED)",
216 "MacBookPro3,2", "Apple SMC MacBook Pro Core 2 Duo (17-inch HD)",
240 "MacBookPro6,2", "Apple SMC MacBook Pro (Mid 2010, 15-inch)",
246 "MacBookPro8,1", "Apple SMC MacBook Pro (early 2011, 13-inch)",
258 "MacBookPro9,1", "Apple SMC MacBook Pro (mid 2012, 15-inch)",
264 "MacBookPro9,2", "Apple SMC MacBook Pro (mid 2012, 13-inch)",
282 "MacBookPro11,4", "Apple SMC MacBook Pro Retina Core i7 (mid 2015, 15-inch)",
314 /* The Mac Mini 4,1 (Mid-2010) has no SMS */
316 "Macmini4,1", "Apple SMC Mac mini 4,1 (Mid-2010)",
324 /* - same sensors as Mac Mini 5,2 */
343 /* - same sensors as Mac Mini 5,2 */
370 /* Idem for the Mac Pro (8-core) */
372 "MacPro2", "Apple SMC Mac Pro (8-core)",
410 "MacBookAir4,1", "Apple SMC Macbook Air 11-inch (Mid 2011)",
418 "MacBookAir4,2", "Apple SMC Macbook Air 13-inch (Mid 2011)",
426 "MacBookAir5,1", "Apple SMC MacBook Air 11-inch (Mid 2012)",
434 "MacBookAir5,2", "Apple SMC MacBook Air 13-inch (Mid 2012)",
441 "MacBookAir6,1", "Apple SMC MacBook Air 11-inch (Early 2013)",
448 "MacBookAir6,2", "Apple SMC MacBook Air 13-inch (Early 2013)",
455 "MacBookAir7,1", "Apple SMC MacBook Air 11-inch (Early 2015)",
462 "MacBookAir7,2", "Apple SMC MacBook Air 13-inch (Early 2015)",
551 device_set_desc(dev, model->smc_desc); in asmc_probe()
567 sc->sc_ioport = bus_alloc_resource_any(dev, SYS_RES_IOPORT, in asmc_attach()
568 &sc->sc_rid_port, RF_ACTIVE); in asmc_attach()
569 if (sc->sc_ioport == NULL) { in asmc_attach()
579 mtx_init(&sc->sc_mtx, "asmc", NULL, MTX_SPIN); in asmc_attach()
581 sc->sc_model = model; in asmc_attach()
585 * dev.asmc.n.fan.* tree. in asmc_attach()
587 sc->sc_fan_tree[0] = SYSCTL_ADD_NODE(sysctlctx, in asmc_attach()
588 SYSCTL_CHILDREN(sysctlnode), OID_AUTO, "fan", in asmc_attach()
589 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "Fan Root Tree"); in asmc_attach()
591 for (i = 1; i <= sc->sc_nfan; i++) { in asmc_attach()
592 j = i - 1; in asmc_attach()
595 sc->sc_fan_tree[i] = SYSCTL_ADD_NODE(sysctlctx, in asmc_attach()
596 SYSCTL_CHILDREN(sc->sc_fan_tree[0]), in asmc_attach()
598 "Fan Subtree"); in asmc_attach()
601 SYSCTL_CHILDREN(sc->sc_fan_tree[i]), in asmc_attach()
604 dev, j, model->smc_fan_id, "I", in asmc_attach()
605 "Fan ID"); in asmc_attach()
608 SYSCTL_CHILDREN(sc->sc_fan_tree[i]), in asmc_attach()
609 OID_AUTO, "speed", in asmc_attach()
611 dev, j, model->smc_fan_speed, "I", in asmc_attach()
612 "Fan speed in RPM"); in asmc_attach()
615 SYSCTL_CHILDREN(sc->sc_fan_tree[i]), in asmc_attach()
618 dev, j, model->smc_fan_safespeed, "I", in asmc_attach()
619 "Fan safe speed in RPM"); in asmc_attach()
622 SYSCTL_CHILDREN(sc->sc_fan_tree[i]), in asmc_attach()
625 dev, j, model->smc_fan_minspeed, "I", in asmc_attach()
626 "Fan minimum speed in RPM"); in asmc_attach()
629 SYSCTL_CHILDREN(sc->sc_fan_tree[i]), in asmc_attach()
632 dev, j, model->smc_fan_maxspeed, "I", in asmc_attach()
633 "Fan maximum speed in RPM"); in asmc_attach()
636 SYSCTL_CHILDREN(sc->sc_fan_tree[i]), in asmc_attach()
639 dev, j, model->smc_fan_targetspeed, "I", in asmc_attach()
640 "Fan target speed in RPM"); in asmc_attach()
646 sc->sc_temp_tree = SYSCTL_ADD_NODE(sysctlctx, in asmc_attach()
650 for (i = 0; model->smc_temps[i]; i++) { in asmc_attach()
652 SYSCTL_CHILDREN(sc->sc_temp_tree), in asmc_attach()
653 OID_AUTO, model->smc_tempnames[i], in asmc_attach()
656 model->smc_tempdescs[i]); in asmc_attach()
662 if (model->smc_light_left) { in asmc_attach()
663 sc->sc_light_tree = SYSCTL_ADD_NODE(sysctlctx, in asmc_attach()
669 SYSCTL_CHILDREN(sc->sc_light_tree), in asmc_attach()
672 dev, 0, model->smc_light_left, "I", in asmc_attach()
676 SYSCTL_CHILDREN(sc->sc_light_tree), in asmc_attach()
679 dev, 0, model->smc_light_right, "I", in asmc_attach()
683 SYSCTL_CHILDREN(sc->sc_light_tree), in asmc_attach()
687 model->smc_light_control, "I", in asmc_attach()
691 if (model->smc_sms_x == NULL) in asmc_attach()
697 sc->sc_sms_tree = SYSCTL_ADD_NODE(sysctlctx, in asmc_attach()
702 SYSCTL_CHILDREN(sc->sc_sms_tree), in asmc_attach()
705 dev, 0, model->smc_sms_x, "I", in asmc_attach()
709 SYSCTL_CHILDREN(sc->sc_sms_tree), in asmc_attach()
712 dev, 0, model->smc_sms_y, "I", in asmc_attach()
716 SYSCTL_CHILDREN(sc->sc_sms_tree), in asmc_attach()
719 dev, 0, model->smc_sms_z, "I", in asmc_attach()
732 sc->sc_sms_tq = NULL; in asmc_attach()
733 TASK_INIT(&sc->sc_sms_task, 0, asmc_sms_task, sc); in asmc_attach()
734 sc->sc_sms_tq = taskqueue_create_fast("asmc_taskq", M_WAITOK, in asmc_attach()
735 taskqueue_thread_enqueue, &sc->sc_sms_tq); in asmc_attach()
736 taskqueue_start_threads(&sc->sc_sms_tq, 1, PI_REALTIME, "%s sms taskq", in asmc_attach()
741 sc->sc_rid_irq = 0; in asmc_attach()
742 sc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, in asmc_attach()
743 &sc->sc_rid_irq, RF_ACTIVE); in asmc_attach()
744 if (sc->sc_irq == NULL) { in asmc_attach()
750 ret = bus_setup_intr(dev, sc->sc_irq, in asmc_attach()
753 dev, &sc->sc_cookie); in asmc_attach()
762 bus_release_resource(dev, SYS_RES_IRQ, sc->sc_rid_irq, sc->sc_irq); in asmc_attach()
764 bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_rid_port, in asmc_attach()
765 sc->sc_ioport); in asmc_attach()
766 mtx_destroy(&sc->sc_mtx); in asmc_attach()
767 if (sc->sc_sms_tq) in asmc_attach()
768 taskqueue_free(sc->sc_sms_tq); in asmc_attach()
778 if (sc->sc_sms_tq) { in asmc_detach()
779 taskqueue_drain(sc->sc_sms_tq, &sc->sc_sms_task); in asmc_detach()
780 taskqueue_free(sc->sc_sms_tq); in asmc_detach()
782 if (sc->sc_cookie) in asmc_detach()
783 bus_teardown_intr(dev, sc->sc_irq, sc->sc_cookie); in asmc_detach()
784 if (sc->sc_irq) in asmc_detach()
785 bus_release_resource(dev, SYS_RES_IRQ, sc->sc_rid_irq, in asmc_detach()
786 sc->sc_irq); in asmc_detach()
787 if (sc->sc_ioport) in asmc_detach()
788 bus_release_resource(dev, SYS_RES_IOPORT, sc->sc_rid_port, in asmc_detach()
789 sc->sc_ioport); in asmc_detach()
790 mtx_destroy(&sc->sc_mtx); in asmc_detach()
823 if (sc->sc_model->smc_sms_x == NULL) in asmc_init()
868 sc->sc_sms_intr_works = 0; in asmc_init()
878 sc->sc_sms_intr_works = 1; in asmc_init()
892 sc->sc_nfan = asmc_fan_count(dev); in asmc_init()
893 if (sc->sc_nfan > ASMC_MAXFANS) { in asmc_init()
896 sc->sc_nfan = ASMC_MAXFANS; in asmc_init()
990 mtx_lock_spin(&sc->sc_mtx); in asmc_key_read()
1018 mtx_unlock_spin(&sc->sc_mtx); in asmc_key_read()
1035 mtx_lock_spin(&sc->sc_mtx); in asmc_key_dump()
1084 mtx_unlock_spin(&sc->sc_mtx); in asmc_key_dump()
1089 mtx_unlock_spin(&sc->sc_mtx); in asmc_key_dump()
1120 int i, error = -1, try = 0; in asmc_key_write()
1123 mtx_lock_spin(&sc->sc_mtx); in asmc_key_write()
1154 mtx_unlock_spin(&sc->sc_mtx); in asmc_key_write()
1161 * Fan control functions.
1169 return (-1); in asmc_fan_count()
1175 asmc_fan_getvalue(device_t dev, const char *key, int fan) in asmc_fan_getvalue() argument
1177 int speed; in asmc_fan_getvalue() local
1181 snprintf(fankey, sizeof(fankey), key, fan); in asmc_fan_getvalue()
1183 return (-1); in asmc_fan_getvalue()
1184 speed = (buf[0] << 6) | (buf[1] >> 2); in asmc_fan_getvalue()
1186 return (speed); in asmc_fan_getvalue()
1190 asmc_fan_getstring(device_t dev, const char *key, int fan, uint8_t *buf, uint8_t buflen) in asmc_fan_getstring() argument
1195 snprintf(fankey, sizeof(fankey), key, fan); in asmc_fan_getstring()
1204 asmc_fan_setvalue(device_t dev, const char *key, int fan, int speed) in asmc_fan_setvalue() argument
1209 speed *= 4; in asmc_fan_setvalue()
1211 buf[0] = speed>>8; in asmc_fan_setvalue()
1212 buf[1] = speed; in asmc_fan_setvalue()
1214 snprintf(fankey, sizeof(fankey), key, fan); in asmc_fan_setvalue()
1216 return (-1); in asmc_fan_setvalue()
1225 int fan = arg2; in asmc_mb_sysctl_fanspeed() local
1229 v = asmc_fan_getvalue(dev, ASMC_KEY_FANSPEED, fan); in asmc_mb_sysctl_fanspeed()
1240 int fan = arg2; in asmc_mb_sysctl_fanid() local
1244 desc = asmc_fan_getstring(dev, ASMC_KEY_FANID, fan, buf, sizeof(buf)); in asmc_mb_sysctl_fanid()
1256 int fan = arg2; in asmc_mb_sysctl_fansafespeed() local
1260 v = asmc_fan_getvalue(dev, ASMC_KEY_FANSAFESPEED, fan); in asmc_mb_sysctl_fansafespeed()
1270 int fan = arg2; in asmc_mb_sysctl_fanminspeed() local
1274 v = asmc_fan_getvalue(dev, ASMC_KEY_FANMINSPEED, fan); in asmc_mb_sysctl_fanminspeed()
1277 if (error == 0 && req->newptr != NULL) { in asmc_mb_sysctl_fanminspeed()
1279 asmc_fan_setvalue(dev, ASMC_KEY_FANMINSPEED, fan, newspeed); in asmc_mb_sysctl_fanminspeed()
1289 int fan = arg2; in asmc_mb_sysctl_fanmaxspeed() local
1293 v = asmc_fan_getvalue(dev, ASMC_KEY_FANMAXSPEED, fan); in asmc_mb_sysctl_fanmaxspeed()
1296 if (error == 0 && req->newptr != NULL) { in asmc_mb_sysctl_fanmaxspeed()
1298 asmc_fan_setvalue(dev, ASMC_KEY_FANMAXSPEED, fan, newspeed); in asmc_mb_sysctl_fanmaxspeed()
1308 int fan = arg2; in asmc_mb_sysctl_fantargetspeed() local
1312 v = asmc_fan_getvalue(dev, ASMC_KEY_FANTARGETSPEED, fan); in asmc_mb_sysctl_fantargetspeed()
1315 if (error == 0 && req->newptr != NULL) { in asmc_mb_sysctl_fantargetspeed()
1317 asmc_fan_setvalue(dev, ASMC_KEY_FANTARGETSPEED, fan, newspeed); in asmc_mb_sysctl_fantargetspeed()
1335 return (-1); in asmc_temp_getvalue()
1347 val = asmc_temp_getvalue(dev, sc->sc_model->smc_temps[arg2]); in asmc_temp_sysctl()
1385 asmc_sms_read(dev, ASMC_KEY_SMS_X, &sc->sms_rest_x); in asmc_sms_calibrate()
1386 asmc_sms_read(dev, ASMC_KEY_SMS_Y, &sc->sms_rest_y); in asmc_sms_calibrate()
1387 asmc_sms_read(dev, ASMC_KEY_SMS_Z, &sc->sms_rest_z); in asmc_sms_calibrate()
1396 if (!sc->sc_sms_intr_works) in asmc_sms_intrfast()
1399 mtx_lock_spin(&sc->sc_mtx); in asmc_sms_intrfast()
1401 mtx_unlock_spin(&sc->sc_mtx); in asmc_sms_intrfast()
1403 sc->sc_sms_intrtype = type; in asmc_sms_intrfast()
1406 taskqueue_enqueue(sc->sc_sms_tq, &sc->sc_sms_task); in asmc_sms_intrfast()
1430 if (strcmp(sc->sc_model->smc_model, "MacBookPro5,5") == 0 || in asmc_sms_printintr()
1431 strcmp(sc->sc_model->smc_model, "MacBookPro6,2") == 0) in asmc_sms_printintr()
1446 switch (sc->sc_sms_intrtype) { in asmc_sms_task()
1550 if (error == 0 && req->newptr != NULL) { in asmc_mbp_sysctl_light_control()
1572 * This seems to be a 32 bit big endian value from buf[6] -> buf[9]. in asmc_mbp_sysctl_light_left_10byte()