dev_dbg(data->bgp->dev, "updated thermal zone %s\n",
thermal_zone_device_type(data->ti_thermal));
}
/** *ti_thermal_hotspot_temperature-returnssensorextrapolatedtemperature *@t:omapsensortemperature *@s:omapsensorslopevalue *@c:omapsensorconstvalue
*/ staticinlineint ti_thermal_hotspot_temperature(int t, int s, int c)
{ int delta = t * s / 1000 + c;
if (delta < 0)
delta = 0;
return t + delta;
}
/* thermal zone ops */ /* Get temperature callback function for thermal zone */ staticinlineint __ti_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{ struct thermal_zone_device *pcb_tz = NULL; struct ti_thermal_data *data = thermal_zone_device_priv(tz); struct ti_bandgap *bgp; conststruct ti_temp_sensor *s; int ret, tmp, slope, constant; int pcb_temp;
if (!data) return0;
bgp = data->bgp;
s = &bgp->conf->sensors[data->sensor_id];
ret = ti_bandgap_read_temperature(bgp, data->sensor_id, &tmp); if (ret) return ret;
pcb_tz = data->pcb_tz; /* In case pcb zone is available, use the extrapolation rule with it */ if (!IS_ERR(pcb_tz)) {
ret = thermal_zone_get_temp(pcb_tz, &pcb_temp); if (!ret) {
tmp -= pcb_temp; /* got a valid PCB temp */
slope = s->slope_pcb;
constant = s->constant_pcb;
} else {
dev_err(bgp->dev, "Failed to read PCB state. Using defaults\n");
ret = 0;
}
}
*temp = ti_thermal_hotspot_temperature(tmp, slope, constant);
data = devm_kzalloc(bgp->dev, sizeof(*data), GFP_KERNEL); if (!data) {
dev_err(bgp->dev, "kzalloc fail\n"); return NULL;
}
data->sensor_id = id;
data->bgp = bgp;
data->mode = THERMAL_DEVICE_ENABLED; /* pcb_tz will be either valid or PTR_ERR() */
data->pcb_tz = thermal_zone_get_zone_by_name("pcb");
INIT_WORK(&data->thermal_wq, ti_thermal_work);
return data;
}
int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, char *domain)
{ struct ti_thermal_data *data;
data = ti_bandgap_get_sensor_data(bgp, id);
if (IS_ERR_OR_NULL(data))
data = ti_thermal_build_data(bgp, id);
if (!data) return -EINVAL;
/* in case this is specified by DT */
data->ti_thermal = devm_thermal_of_zone_register(bgp->dev, id,
data, &ti_of_thermal_ops); if (IS_ERR(data->ti_thermal)) {
dev_err(bgp->dev, "thermal zone device is NULL\n"); return PTR_ERR(data->ti_thermal);
}
int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id)
{ struct ti_thermal_data *data;
data = ti_bandgap_get_sensor_data(bgp, id);
if (!IS_ERR_OR_NULL(data) && data->ti_thermal) { if (data->our_zone)
thermal_zone_device_unregister(data->ti_thermal);
}
return0;
}
int ti_thermal_report_sensor_temperature(struct ti_bandgap *bgp, int id)
{ struct ti_thermal_data *data;
data = ti_bandgap_get_sensor_data(bgp, id);
schedule_work(&data->thermal_wq);
return0;
}
int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id)
{ struct ti_thermal_data *data; struct device_node *np = bgp->dev->of_node;
/* *Weareassumingherethatifonedeploysthezone *usingDT,thenitmustbeawarethatthecoolingdevice *loadinghastohappenviacpufreqdriver.
*/ if (of_property_present(np, "#thermal-sensor-cells")) return0;
data = ti_bandgap_get_sensor_data(bgp, id); if (!data || IS_ERR(data))
data = ti_thermal_build_data(bgp, id);
if (!data) return -EINVAL;
data->policy = cpufreq_cpu_get(0); if (!data->policy) {
pr_debug("%s: CPUFreq policy not found\n", __func__); return -EPROBE_DEFER;
}
/* Register cooling device */
data->cool_dev = cpufreq_cooling_register(data->policy); if (IS_ERR(data->cool_dev)) { int ret = PTR_ERR(data->cool_dev);
dev_err(bgp->dev, "Failed to register cpu cooling device %d\n",
ret);
cpufreq_cpu_put(data->policy);
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.