drivers/thermal/ti-soc-thermal/ti-thermal-common.c
Source file repositories/reference/linux-study-clean/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/ti-soc-thermal/ti-thermal-common.c- Extension
.c- Size
- 6438 bytes
- Lines
- 272
- Domain
- Driver Families
- Bucket
- drivers/thermal
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/err.hlinux/mutex.hlinux/gfp.hlinux/kernel.hlinux/workqueue.hlinux/thermal.hlinux/cpufreq.hlinux/cpumask.hlinux/cpu_cooling.hlinux/of.hti-thermal.hti-bandgap.h../thermal_hwmon.h
Detected Declarations
struct ti_thermal_datafunction ti_thermal_workfunction ti_thermal_hotspot_temperaturefunction __ti_thermal_get_tempfunction __ti_thermal_get_trendfunction ti_thermal_expose_sensorfunction ti_thermal_remove_sensorfunction ti_thermal_report_sensor_temperaturefunction ti_thermal_register_cpu_coolingfunction ti_thermal_unregister_cpu_cooling
Annotated Snippet
struct ti_thermal_data {
struct cpufreq_policy *policy;
struct thermal_zone_device *ti_thermal;
struct thermal_zone_device *pcb_tz;
struct thermal_cooling_device *cool_dev;
struct ti_bandgap *bgp;
enum thermal_device_mode mode;
struct work_struct thermal_wq;
int sensor_id;
bool our_zone;
};
static void ti_thermal_work(struct work_struct *work)
{
struct ti_thermal_data *data = container_of(work,
struct ti_thermal_data, thermal_wq);
thermal_zone_device_update(data->ti_thermal, THERMAL_EVENT_UNSPECIFIED);
dev_dbg(data->bgp->dev, "updated thermal zone %s\n",
thermal_zone_device_type(data->ti_thermal));
}
/**
* ti_thermal_hotspot_temperature - returns sensor extrapolated temperature
* @t: omap sensor temperature
* @s: omap sensor slope value
* @c: omap sensor const value
*/
static inline int 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 */
static inline int __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;
const struct ti_temp_sensor *s;
int ret, tmp, slope, constant;
int pcb_temp;
if (!data)
return 0;
bgp = data->bgp;
s = &bgp->conf->sensors[data->sensor_id];
ret = ti_bandgap_read_temperature(bgp, data->sensor_id, &tmp);
if (ret)
return ret;
/* Default constants */
slope = thermal_zone_get_slope(tz);
constant = thermal_zone_get_offset(tz);
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);
return ret;
}
static int __ti_thermal_get_trend(struct thermal_zone_device *tz,
const struct thermal_trip *trip,
enum thermal_trend *trend)
{
struct ti_thermal_data *data = thermal_zone_device_priv(tz);
struct ti_bandgap *bgp;
int id, tr, ret = 0;
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/mutex.h`, `linux/gfp.h`, `linux/kernel.h`, `linux/workqueue.h`, `linux/thermal.h`, `linux/cpufreq.h`.
- Detected declarations: `struct ti_thermal_data`, `function ti_thermal_work`, `function ti_thermal_hotspot_temperature`, `function __ti_thermal_get_temp`, `function __ti_thermal_get_trend`, `function ti_thermal_expose_sensor`, `function ti_thermal_remove_sensor`, `function ti_thermal_report_sensor_temperature`, `function ti_thermal_register_cpu_cooling`, `function ti_thermal_unregister_cpu_cooling`.
- Atlas domain: Driver Families / drivers/thermal.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.