/* * Various SMU "partitions" calibration objects for which we * keep pointers here for use by bits & pieces of the driver
*/ staticstruct smu_sdbp_cpuvcp *cpuvcp; staticint cpuvcp_version; staticstruct smu_sdbp_cpudiode *cpudiode; staticstruct smu_sdbp_slotspow *slotspow; static u8 *debugswitches;
ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL); if (ads == NULL) return NULL;
l = of_get_property(node, "location", NULL); if (l == NULL) goto fail;
/* We currently pick the sensors based on the OF name and location * properties, while Darwin uses the sensor-id's. * The problem with the IDs is that they are model specific while it * looks like apple has been doing a reasonably good job at keeping * the names and locations consistents so I'll stick with the names * and locations for now.
*/ if (of_node_is_type(node, "temp-sensor") &&
!strcmp(l, "CPU T-Diode")) {
ads->sens.ops = &smu_cputemp_ops;
ads->sens.name = "cpu-temp"; if (cpudiode == NULL) {
DBG("wf: cpudiode partition (%02x) not found\n",
SMU_SDB_CPUDIODE_ID); goto fail;
}
} elseif (of_node_is_type(node, "current-sensor") &&
!strcmp(l, "CPU Current")) {
ads->sens.ops = &smu_cpuamp_ops;
ads->sens.name = "cpu-current"; if (cpuvcp == NULL) {
DBG("wf: cpuvcp partition (%02x) not found\n",
SMU_SDB_CPUVCP_ID); goto fail;
}
} elseif (of_node_is_type(node, "voltage-sensor") &&
!strcmp(l, "CPU Voltage")) {
ads->sens.ops = &smu_cpuvolt_ops;
ads->sens.name = "cpu-voltage"; if (cpuvcp == NULL) {
DBG("wf: cpuvcp partition (%02x) not found\n",
SMU_SDB_CPUVCP_ID); goto fail;
}
} elseif (of_node_is_type(node, "power-sensor") &&
!strcmp(l, "Slots Power")) {
ads->sens.ops = &smu_slotspow_ops;
ads->sens.name = "slots-power"; if (slotspow == NULL) {
DBG("wf: slotspow partition (%02x) not found\n",
SMU_SDB_SLOTSPOW_ID); goto fail;
}
} else goto fail;
v = of_get_property(node, "reg", NULL); if (v == NULL) goto fail;
ads->reg = *v;
/* Some early machines need a faked voltage */ if (debugswitches && ((*debugswitches) & 0x80)) {
printk(KERN_INFO "windfarm: CPU Power sensor using faked" " voltage !\n");
pow->fake_volts = 1;
} else
pow->fake_volts = 0;
/* Try to use quadratic transforms on PowerMac8,1 and 9,1 for now, * I yet have to figure out what's up with 8,2 and will have to * adjust for later, unless we can 100% trust the SDB partition...
*/ if ((of_machine_is_compatible("PowerMac8,1") ||
of_machine_is_compatible("PowerMac8,2") ||
of_machine_is_compatible("PowerMac9,1")) &&
cpuvcp_version >= 2) {
pow->quadratic = 1;
DBG("windfarm: CPU Power using quadratic transform\n");
} else
pow->quadratic = 0;
/* Get CPU voltage/current/power calibration data */
hdr = smu_get_sdb_partition(SMU_SDB_CPUVCP_ID, NULL); if (hdr != NULL) {
cpuvcp = (struct smu_sdbp_cpuvcp *)&hdr[1]; /* Keep version around */
cpuvcp_version = hdr->version;
}
/* Get CPU diode calibration data */
hdr = smu_get_sdb_partition(SMU_SDB_CPUDIODE_ID, NULL); if (hdr != NULL)
cpudiode = (struct smu_sdbp_cpudiode *)&hdr[1];
/* Get slots power calibration data if any */
hdr = smu_get_sdb_partition(SMU_SDB_SLOTSPOW_ID, NULL); if (hdr != NULL)
slotspow = (struct smu_sdbp_slotspow *)&hdr[1];
/* Get debug switches if any */
hdr = smu_get_sdb_partition(SMU_SDB_DEBUG_SWITCHES_ID, NULL); if (hdr != NULL)
debugswitches = (u8 *)&hdr[1];
}
/* Get parameters partitions */
smu_fetch_param_partitions();
smu = of_find_node_by_type(NULL, "smu"); if (smu == NULL) return -ENODEV;
/* Look for sensors subdir */
for_each_child_of_node(smu, sensors) if (of_node_name_eq(sensors, "sensors")) break;
of_node_put(smu);
/* Create basic sensors */ for (s = NULL;
sensors && (s = of_get_next_child(sensors, s)) != NULL;) { struct smu_ad_sensor *ads;
ads = smu_ads_create(s); if (ads == NULL) continue;
list_add(&ads->link, &smu_ads); /* keep track of cpu voltage & current */ if (!strcmp(ads->sens.name, "cpu-voltage"))
volt_sensor = ads; elseif (!strcmp(ads->sens.name, "cpu-current"))
curr_sensor = ads;
}
of_node_put(sensors);
/* Create CPU power sensor if possible */ if (volt_sensor && curr_sensor)
smu_cpu_power = smu_cpu_power_create(&volt_sensor->sens,
&curr_sensor->sens);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.