Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iicbus/adt746x.c
Show All 12 Lines | |||||
if (sc->sc_nfans == 0) { | if (sc->sc_nfans == 0) { | ||||
device_printf(dev, "WARNING: No fans detected!\n"); | device_printf(dev, "WARNING: No fans detected!\n"); | ||||
return; | return; | ||||
} | } | ||||
ctx = device_get_sysctl_ctx(dev); | ctx = device_get_sysctl_ctx(dev); | ||||
fanroot_oid = SYSCTL_ADD_NODE(ctx, | fanroot_oid = SYSCTL_ADD_NODE(ctx, | ||||
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "fans", | SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "fans", | ||||
CTLFLAG_RD, 0, "ADT Fan Information"); | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "ADT Fan Information"); | ||||
/* Now we can fill the properties into the allocated struct. */ | /* Now we can fill the properties into the allocated struct. */ | ||||
sc->sc_nfans = adt746x_fill_fan_prop(dev); | sc->sc_nfans = adt746x_fill_fan_prop(dev); | ||||
/* Register fans with pmac_thermal */ | /* Register fans with pmac_thermal */ | ||||
for (i = 0; i < sc->sc_nfans; i++) | for (i = 0; i < sc->sc_nfans; i++) | ||||
pmac_thermal_fan_register(&sc->sc_fans[i].fan); | pmac_thermal_fan_register(&sc->sc_fans[i].fan); | ||||
/* Add sysctls for the fans. */ | /* Add sysctls for the fans. */ | ||||
for (i = 0; i < sc->sc_nfans; i++) { | for (i = 0; i < sc->sc_nfans; i++) { | ||||
for (j = 0; j < strlen(sc->sc_fans[i].fan.name); j++) { | for (j = 0; j < strlen(sc->sc_fans[i].fan.name); j++) { | ||||
sysctl_name[j] = tolower(sc->sc_fans[i].fan.name[j]); | sysctl_name[j] = tolower(sc->sc_fans[i].fan.name[j]); | ||||
if (isspace(sysctl_name[j])) | if (isspace(sysctl_name[j])) | ||||
sysctl_name[j] = '_'; | sysctl_name[j] = '_'; | ||||
} | } | ||||
sysctl_name[j] = 0; | sysctl_name[j] = 0; | ||||
sc->sc_fans[i].setpoint = | sc->sc_fans[i].setpoint = | ||||
adt746x_fan_get_pwm(&sc->sc_fans[i]); | adt746x_fan_get_pwm(&sc->sc_fans[i]); | ||||
oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(fanroot_oid), | oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(fanroot_oid), | ||||
OID_AUTO, sysctl_name, CTLFLAG_RD, 0, "Fan Information"); | OID_AUTO, sysctl_name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, | ||||
"Fan Information"); | |||||
/* I use i to pass the fan id. */ | /* I use i to pass the fan id. */ | ||||
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, | SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, | ||||
"pwm", CTLTYPE_INT | CTLFLAG_RW, dev, i, | "pwm", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, dev, | ||||
adt746x_fanrpm_sysctl, "I", "Fan PWM in %"); | i, adt746x_fanrpm_sysctl, "I", "Fan PWM in %"); | ||||
} | } | ||||
/* Dump fan location & type. */ | /* Dump fan location & type. */ | ||||
if (bootverbose) { | if (bootverbose) { | ||||
for (i = 0; i < sc->sc_nfans; i++) { | for (i = 0; i < sc->sc_nfans; i++) { | ||||
device_printf(dev, "Fan location: %s", | device_printf(dev, "Fan location: %s", | ||||
sc->sc_fans[i].fan.name); | sc->sc_fans[i].fan.name); | ||||
device_printf(dev, " id: %d RPM: %d\n", | device_printf(dev, " id: %d RPM: %d\n", | ||||
Show All 24 Lines | |||||
if (sc->sc_nsensors == 0) { | if (sc->sc_nsensors == 0) { | ||||
device_printf(dev, "WARNING: No sensors detected!\n"); | device_printf(dev, "WARNING: No sensors detected!\n"); | ||||
return; | return; | ||||
} | } | ||||
ctx = device_get_sysctl_ctx(dev); | ctx = device_get_sysctl_ctx(dev); | ||||
sensroot_oid = SYSCTL_ADD_NODE(ctx, | sensroot_oid = SYSCTL_ADD_NODE(ctx, | ||||
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "sensors", | SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "sensors", | ||||
CTLFLAG_RD, 0, "ADT Sensor Information"); | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "ADT Sensor Information"); | ||||
/* Add the sysctl for the sensors. */ | /* Add the sysctl for the sensors. */ | ||||
for (i = 0; i < sc->sc_nsensors; i++) { | for (i = 0; i < sc->sc_nsensors; i++) { | ||||
for (j = 0; j < strlen(sc->sc_sensors[i].therm.name); j++) { | for (j = 0; j < strlen(sc->sc_sensors[i].therm.name); j++) { | ||||
sysctl_name[j] = tolower(sc->sc_sensors[i].therm.name[j]); | sysctl_name[j] = tolower(sc->sc_sensors[i].therm.name[j]); | ||||
if (isspace(sysctl_name[j])) | if (isspace(sysctl_name[j])) | ||||
sysctl_name[j] = '_'; | sysctl_name[j] = '_'; | ||||
} | } | ||||
sysctl_name[j] = 0; | sysctl_name[j] = 0; | ||||
oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(sensroot_oid), | oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(sensroot_oid), | ||||
OID_AUTO, | OID_AUTO, sysctl_name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, | ||||
sysctl_name, CTLFLAG_RD, 0, | "Sensor Information"); | ||||
"Sensor Information"); | |||||
if (sc->sc_sensors[i].type == ADT746X_SENSOR_TEMP) { | if (sc->sc_sensors[i].type == ADT746X_SENSOR_TEMP) { | ||||
unit = "temp"; | unit = "temp"; | ||||
desc = "sensor unit (C)"; | desc = "sensor unit (C)"; | ||||
} else if (sc->sc_sensors[i].type == ADT746X_SENSOR_VOLT) { | } else if (sc->sc_sensors[i].type == ADT746X_SENSOR_VOLT) { | ||||
unit = "volt"; | unit = "volt"; | ||||
desc = "sensor unit (mV)"; | desc = "sensor unit (mV)"; | ||||
} else { | } else { | ||||
unit = "rpm"; | unit = "rpm"; | ||||
desc = "sensor unit (RPM)"; | desc = "sensor unit (RPM)"; | ||||
} | } | ||||
/* I use i to pass the sensor id. */ | /* I use i to pass the sensor id. */ | ||||
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, | SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, | ||||
unit, CTLTYPE_INT | CTLFLAG_RD, dev, i, | unit, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, dev, i, | ||||
adt746x_sensor_sysctl, | adt746x_sensor_sysctl, | ||||
sc->sc_sensors[i].type == ADT746X_SENSOR_TEMP ? | sc->sc_sensors[i].type == ADT746X_SENSOR_TEMP ? | ||||
"IK" : "I", desc); | "IK" : "I", desc); | ||||
} | } | ||||
/* Dump sensor location & type. */ | /* Dump sensor location & type. */ | ||||
if (bootverbose) { | if (bootverbose) { | ||||
for (i = 0; i < sc->sc_nsensors; i++) { | for (i = 0; i < sc->sc_nsensors; i++) { | ||||
device_printf(dev, "Sensor location: %s", | device_printf(dev, "Sensor location: %s", | ||||
sc->sc_sensors[i].therm.name); | sc->sc_sensors[i].therm.name); | ||||
device_printf(dev, " type: %d id: %d reg: 0x%x\n", | device_printf(dev, " type: %d id: %d reg: 0x%x\n", | ||||
sc->sc_sensors[i].type, | sc->sc_sensors[i].type, | ||||
sc->sc_sensors[i].id, | sc->sc_sensors[i].id, | ||||
sc->sc_sensors[i].reg); | sc->sc_sensors[i].reg); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Context not available. |