drivers/thermal/tegra/tegra-bpmp-thermal.c
Source file repositories/reference/linux-study-clean/drivers/thermal/tegra/tegra-bpmp-thermal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/tegra/tegra-bpmp-thermal.c- Extension
.c- Size
- 8068 bytes
- Lines
- 329
- 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/err.hlinux/module.hlinux/platform_device.hlinux/thermal.hlinux/workqueue.hsoc/tegra/bpmp.hsoc/tegra/bpmp-abi.h
Detected Declarations
struct tegra_bpmp_thermal_zonestruct tegra_bpmp_thermalfunction __tegra_bpmp_thermal_get_tempfunction tegra_bpmp_thermal_get_tempfunction tegra_bpmp_thermal_set_tripsfunction tz_device_update_work_fnfunction bpmp_mrq_thermalfunction tegra_bpmp_thermal_get_num_zonesfunction tegra_bpmp_thermal_trips_supportedfunction tegra_bpmp_thermal_probefunction tegra_bpmp_thermal_remove
Annotated Snippet
struct tegra_bpmp_thermal_zone {
struct tegra_bpmp_thermal *tegra;
struct thermal_zone_device *tzd;
struct work_struct tz_device_update_work;
unsigned int idx;
};
struct tegra_bpmp_thermal {
struct device *dev;
struct tegra_bpmp *bpmp;
unsigned int num_zones;
struct tegra_bpmp_thermal_zone **zones;
};
static int __tegra_bpmp_thermal_get_temp(struct tegra_bpmp_thermal_zone *zone,
int *out_temp)
{
struct mrq_thermal_host_to_bpmp_request req;
union mrq_thermal_bpmp_to_host_response reply;
struct tegra_bpmp_message msg;
int err;
memset(&req, 0, sizeof(req));
req.type = CMD_THERMAL_GET_TEMP;
req.get_temp.zone = zone->idx;
memset(&msg, 0, sizeof(msg));
msg.mrq = MRQ_THERMAL;
msg.tx.data = &req;
msg.tx.size = sizeof(req);
msg.rx.data = &reply;
msg.rx.size = sizeof(reply);
err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg);
if (err)
return err;
if (msg.rx.ret == -BPMP_EFAULT)
return -EAGAIN;
if (msg.rx.ret)
return -EINVAL;
*out_temp = reply.get_temp.temp;
return 0;
}
static int tegra_bpmp_thermal_get_temp(struct thermal_zone_device *tz, int *out_temp)
{
struct tegra_bpmp_thermal_zone *zone = thermal_zone_device_priv(tz);
return __tegra_bpmp_thermal_get_temp(zone, out_temp);
}
static int tegra_bpmp_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
{
struct tegra_bpmp_thermal_zone *zone = thermal_zone_device_priv(tz);
struct mrq_thermal_host_to_bpmp_request req;
struct tegra_bpmp_message msg;
int err;
memset(&req, 0, sizeof(req));
req.type = CMD_THERMAL_SET_TRIP;
req.set_trip.zone = zone->idx;
req.set_trip.enabled = true;
req.set_trip.low = low;
req.set_trip.high = high;
memset(&msg, 0, sizeof(msg));
msg.mrq = MRQ_THERMAL;
msg.tx.data = &req;
msg.tx.size = sizeof(req);
err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg);
if (err)
return err;
if (msg.rx.ret)
return -EINVAL;
return 0;
}
static void tz_device_update_work_fn(struct work_struct *work)
{
struct tegra_bpmp_thermal_zone *zone;
zone = container_of(work, struct tegra_bpmp_thermal_zone,
tz_device_update_work);
thermal_zone_device_update(zone->tzd, THERMAL_TRIP_VIOLATED);
}
Annotation
- Immediate include surface: `linux/err.h`, `linux/module.h`, `linux/platform_device.h`, `linux/thermal.h`, `linux/workqueue.h`, `soc/tegra/bpmp.h`, `soc/tegra/bpmp-abi.h`.
- Detected declarations: `struct tegra_bpmp_thermal_zone`, `struct tegra_bpmp_thermal`, `function __tegra_bpmp_thermal_get_temp`, `function tegra_bpmp_thermal_get_temp`, `function tegra_bpmp_thermal_set_trips`, `function tz_device_update_work_fn`, `function bpmp_mrq_thermal`, `function tegra_bpmp_thermal_get_num_zones`, `function tegra_bpmp_thermal_trips_supported`, `function tegra_bpmp_thermal_probe`.
- 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.