drivers/thermal/tegra/tegra30-tsensor.c
Source file repositories/reference/linux-study-clean/drivers/thermal/tegra/tegra30-tsensor.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/tegra/tegra30-tsensor.c- Extension
.c- Size
- 18237 bytes
- Lines
- 679
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bitfield.hlinux/clk.hlinux/delay.hlinux/errno.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/math.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm.hlinux/reset.hlinux/slab.hlinux/thermal.hlinux/types.hsoc/tegra/fuse.h../thermal_hwmon.h
Detected Declarations
struct tegra_tsensorstruct tegra_tsensor_calibration_datastruct tegra_tsensor_channelstruct tegra_tsensorstruct trip_tempsfunction tegra_tsensor_hw_enablefunction tegra_tsensor_hw_disablefunction devm_tegra_tsensor_hw_disablefunction tegra_tsensor_get_tempfunction tegra_tsensor_temp_to_counterfunction tegra_tsensor_set_tripsfunction tegra_tsensor_handle_channel_interruptfunction tegra_tsensor_isrfunction tegra_tsensor_disable_hw_channelfunction tegra_tsensor_get_trips_cbfunction tegra_tsensor_get_hw_channel_tripsfunction tegra_tsensor_enable_hw_channelfunction tegra_tsensor_fuse_read_sparefunction tegra_tsensor_nvmem_setupfunction tegra_tsensor_register_channelfunction tegra_tsensor_probefunction tegra_tsensor_suspendfunction tegra_tsensor_resume
Annotated Snippet
struct tegra_tsensor_calibration_data {
int a, b, m, n, p, r;
};
struct tegra_tsensor_channel {
void __iomem *regs;
unsigned int id;
struct tegra_tsensor *ts;
struct thermal_zone_device *tzd;
};
struct tegra_tsensor {
void __iomem *regs;
bool swap_channels;
struct clk *clk;
struct device *dev;
struct reset_control *rst;
struct tegra_tsensor_channel ch[2];
struct tegra_tsensor_calibration_data calib;
};
static int tegra_tsensor_hw_enable(const struct tegra_tsensor *ts)
{
u32 val;
int err;
err = reset_control_assert(ts->rst);
if (err) {
dev_err(ts->dev, "failed to assert hardware reset: %d\n", err);
return err;
}
err = clk_prepare_enable(ts->clk);
if (err) {
dev_err(ts->dev, "failed to enable clock: %d\n", err);
return err;
}
fsleep(1000);
err = reset_control_deassert(ts->rst);
if (err) {
dev_err(ts->dev, "failed to deassert hardware reset: %d\n", err);
goto disable_clk;
}
/*
* Sensors are enabled after reset by default, but not gauging
* until clock counter is programmed.
*
* M: number of reference clock pulses after which every
* temperature / voltage measurement is made
*
* N: number of reference clock counts for which the counter runs
*/
val = FIELD_PREP(TSENSOR_SENSOR0_CONFIG0_M, 12500);
val |= FIELD_PREP(TSENSOR_SENSOR0_CONFIG0_N, 255);
/* apply the same configuration to both channels */
writel_relaxed(val, ts->regs + 0x40 + TSENSOR_SENSOR0_CONFIG0);
writel_relaxed(val, ts->regs + 0x80 + TSENSOR_SENSOR0_CONFIG0);
return 0;
disable_clk:
clk_disable_unprepare(ts->clk);
return err;
}
static int tegra_tsensor_hw_disable(const struct tegra_tsensor *ts)
{
int err;
err = reset_control_assert(ts->rst);
if (err) {
dev_err(ts->dev, "failed to assert hardware reset: %d\n", err);
return err;
}
clk_disable_unprepare(ts->clk);
return 0;
}
static void devm_tegra_tsensor_hw_disable(void *data)
{
const struct tegra_tsensor *ts = data;
tegra_tsensor_hw_disable(ts);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/errno.h`, `linux/interrupt.h`, `linux/io.h`, `linux/iopoll.h`, `linux/math.h`.
- Detected declarations: `struct tegra_tsensor`, `struct tegra_tsensor_calibration_data`, `struct tegra_tsensor_channel`, `struct tegra_tsensor`, `struct trip_temps`, `function tegra_tsensor_hw_enable`, `function tegra_tsensor_hw_disable`, `function devm_tegra_tsensor_hw_disable`, `function tegra_tsensor_get_temp`, `function tegra_tsensor_temp_to_counter`.
- Atlas domain: Driver Families / drivers/thermal.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.