drivers/thermal/samsung/exynos_tmu.c
Source file repositories/reference/linux-study-clean/drivers/thermal/samsung/exynos_tmu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/samsung/exynos_tmu.c- Extension
.c- Size
- 34068 bytes
- Lines
- 1176
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/clk.hlinux/io.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hlinux/regulator/consumer.hlinux/thermal.hdt-bindings/thermal/thermal_exynos.h
Detected Declarations
struct exynos_tmu_dataenum soc_typefunction temp_to_codefunction code_to_tempfunction sanitize_temp_errorfunction exynos_tmu_initializefunction exynos_thermal_zone_configurefunction get_con_regfunction exynos_tmu_controlfunction exynos_tmu_update_bitfunction exynos_tmu_update_tempfunction exynos4210_tmu_set_low_tempfunction exynos4210_tmu_disable_lowfunction exynos4210_tmu_set_crit_tempfunction exynos4210_tmu_initializefunction exynos4412_tmu_set_low_tempfunction exynos4412_tmu_set_high_tempfunction exynos4412_tmu_disable_lowfunction exynos4412_tmu_set_crit_tempfunction exynos4412_tmu_initializefunction exynos5433_tmu_set_low_tempfunction exynos5433_tmu_set_high_tempfunction exynos5433_tmu_disable_lowfunction exynos5433_tmu_disable_highfunction exynos5433_tmu_set_crit_tempfunction exynos5433_tmu_initializefunction exynos7_tmu_set_low_tempfunction exynos7_tmu_set_high_tempfunction exynos7_tmu_disable_lowfunction exynos7_tmu_disable_highfunction exynos7_tmu_set_crit_tempfunction exynos7_tmu_initializefunction exynos4210_tmu_controlfunction exynos5433_tmu_controlfunction exynos7_tmu_controlfunction exynos_get_tempfunction get_emul_con_regfunction exynos4412_tmu_set_emulationfunction exynos_tmu_set_emulationfunction exynos_tmu_set_emulationfunction exynos4210_tmu_readfunction exynos4412_tmu_readfunction exynos7_tmu_readfunction exynos_tmu_threaded_irqfunction exynos4210_tmu_clear_irqsfunction exynos_map_dt_datafunction exynos_set_tripsfunction exynos_tmu_probe
Annotated Snippet
struct exynos_tmu_data {
void __iomem *base;
void __iomem *base_second;
int irq;
enum soc_type soc;
struct mutex lock;
struct clk *clk, *clk_sec, *sclk;
u32 cal_type;
u32 efuse_value;
u32 min_efuse_value;
u32 max_efuse_value;
u16 temp_error1, temp_error2;
u8 gain;
u8 reference_voltage;
struct thermal_zone_device *tzd;
bool enabled;
void (*tmu_set_low_temp)(struct exynos_tmu_data *data, u8 temp);
void (*tmu_set_high_temp)(struct exynos_tmu_data *data, u8 temp);
void (*tmu_set_crit_temp)(struct exynos_tmu_data *data, u8 temp);
void (*tmu_disable_low)(struct exynos_tmu_data *data);
void (*tmu_disable_high)(struct exynos_tmu_data *data);
void (*tmu_initialize)(struct platform_device *pdev);
void (*tmu_control)(struct platform_device *pdev, bool on);
int (*tmu_read)(struct exynos_tmu_data *data);
void (*tmu_set_emulation)(struct exynos_tmu_data *data, int temp);
void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
};
/*
* TMU treats temperature as a mapped temperature code.
* The temperature is converted differently depending on the calibration type.
*/
static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
{
if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
return temp + data->temp_error1 - EXYNOS_FIRST_POINT_TRIM;
return (temp - EXYNOS_FIRST_POINT_TRIM) *
(data->temp_error2 - data->temp_error1) /
(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) +
data->temp_error1;
}
/*
* Calculate a temperature value from a temperature code.
* The unit of the temperature is degree Celsius.
*/
static int code_to_temp(struct exynos_tmu_data *data, u16 temp_code)
{
if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
return temp_code - data->temp_error1 + EXYNOS_FIRST_POINT_TRIM;
return (temp_code - data->temp_error1) *
(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) /
(data->temp_error2 - data->temp_error1) +
EXYNOS_FIRST_POINT_TRIM;
}
static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
{
u16 tmu_temp_mask =
(data->soc == SOC_ARCH_EXYNOS7) ? EXYNOS7_TMU_TEMP_MASK
: EXYNOS_TMU_TEMP_MASK;
data->temp_error1 = trim_info & tmu_temp_mask;
data->temp_error2 = ((trim_info >> EXYNOS_TRIMINFO_85_SHIFT) &
EXYNOS_TMU_TEMP_MASK);
if (!data->temp_error1 ||
(data->min_efuse_value > data->temp_error1) ||
(data->temp_error1 > data->max_efuse_value))
data->temp_error1 = data->efuse_value & EXYNOS_TMU_TEMP_MASK;
if (!data->temp_error2)
data->temp_error2 =
(data->efuse_value >> EXYNOS_TRIMINFO_85_SHIFT) &
EXYNOS_TMU_TEMP_MASK;
}
static int exynos_tmu_initialize(struct platform_device *pdev)
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
unsigned int status;
int ret = 0;
mutex_lock(&data->lock);
clk_enable(data->clk);
if (!IS_ERR(data->clk_sec))
clk_enable(data->clk_sec);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/io.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_irq.h`, `linux/platform_device.h`.
- Detected declarations: `struct exynos_tmu_data`, `enum soc_type`, `function temp_to_code`, `function code_to_temp`, `function sanitize_temp_error`, `function exynos_tmu_initialize`, `function exynos_thermal_zone_configure`, `function get_con_reg`, `function exynos_tmu_control`, `function exynos_tmu_update_bit`.
- Atlas domain: Driver Families / drivers/thermal.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.