drivers/thermal/mediatek/lvts_thermal.c
Source file repositories/reference/linux-study-clean/drivers/thermal/mediatek/lvts_thermal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/mediatek/lvts_thermal.c- Extension
.c- Size
- 61286 bytes
- Lines
- 2208
- 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/clk.hlinux/clk-provider.hlinux/delay.hlinux/debugfs.hlinux/init.hlinux/interrupt.hlinux/iopoll.hlinux/kernel.hlinux/nvmem-consumer.hlinux/of.hlinux/platform_device.hlinux/reset.hlinux/thermal.hdt-bindings/thermal/mediatek,lvts-thermal.h../thermal_hwmon.h
Detected Declarations
struct lvts_sensor_datastruct lvts_ctrl_datastruct lvts_platform_opsstruct lvts_datastruct lvts_sensorstruct lvts_ctrlstruct lvts_domainenum lvts_msr_modefunction lvts_debugfs_exitfunction lvts_debugfs_initfunction lvts_debugfs_initfunction lvts_raw_to_tempfunction lvts_temp_to_rawfunction lvts_raw_to_temp_mt7988function lvts_temp_to_raw_mt7988function lvts_temp_to_raw_mt8196function lvts_get_tempfunction lvts_update_irq_maskfunction lvts_for_each_valid_sensorfunction lvts_should_update_threshfunction lvts_set_tripsfunction lvts_ctrl_irq_handlerfunction downfunction lvts_sensor_initfunction lvts_for_each_valid_sensorfunction lvts_decode_sensor_calibrationfunction lvts_calibration_initfunction lvts_for_each_valid_sensorfunction lvts_calibration_readfunction of_property_for_each_stringfunction lvts_golden_temp_initfunction lvts_ctrl_initfunction lvts_ctrl_monitor_enablefunction lvts_write_configfunction lvts_irq_initfunction lvts_domain_resetfunction lvts_ctrl_set_enablefunction lvts_ctrl_connectfunction lvts_ctrl_initializefunction lvts_ctrl_calibratefunction lvts_ctrl_configurefunction lvts_ctrl_startfunction lvts_for_each_valid_sensorfunction lvts_domain_initfunction lvts_probefunction lvts_removefunction lvts_suspendfunction lvts_resume
Annotated Snippet
struct lvts_sensor_data {
int dt_id;
u8 cal_offsets[LVTS_MAX_CAL_OFFSETS];
};
struct lvts_ctrl_data {
struct lvts_sensor_data lvts_sensor[LVTS_SENSOR_MAX];
u8 valid_sensor_mask;
int offset;
enum lvts_msr_mode mode;
};
#define VALID_SENSOR_MAP(s0, s1, s2, s3) \
.valid_sensor_mask = (((s0) ? BIT(0) : 0) | \
((s1) ? BIT(1) : 0) | \
((s2) ? BIT(2) : 0) | \
((s3) ? BIT(3) : 0))
#define lvts_for_each_valid_sensor(i, lvts_ctrl) \
for ((i) = 0; (i) < LVTS_SENSOR_MAX; (i)++) \
if (!((lvts_ctrl)->valid_sensor_mask & BIT(i))) \
continue; \
else
struct lvts_platform_ops {
int (*lvts_raw_to_temp)(u32 raw_temp, int temp_factor);
u32 (*lvts_temp_to_raw)(int temperature, int temp_factor);
};
struct lvts_data {
const struct lvts_ctrl_data *lvts_ctrl;
const struct lvts_platform_ops *ops;
const u32 *conn_cmd;
const u32 *init_cmd;
int num_cal_offsets;
int num_lvts_ctrl;
int num_conn_cmd;
int num_init_cmd;
int temp_factor;
int temp_offset;
int gt_calib_bit_offset;
unsigned int def_calibration;
u16 msr_offset;
};
struct lvts_sensor {
struct thermal_zone_device *tz;
void __iomem *msr;
void __iomem *base;
int id;
int dt_id;
int low_thresh;
int high_thresh;
};
struct lvts_ctrl {
struct lvts_sensor sensors[LVTS_SENSOR_MAX];
const struct lvts_data *lvts_data;
u32 calibration[LVTS_SENSOR_MAX];
u8 valid_sensor_mask;
int mode;
void __iomem *base;
int low_thresh;
int high_thresh;
};
struct lvts_domain {
struct lvts_ctrl *lvts_ctrl;
struct reset_control *reset;
struct clk *clk;
int num_lvts_ctrl;
void __iomem *base;
size_t calib_len;
u8 *calib;
#ifdef CONFIG_DEBUG_FS
struct dentry *dom_dentry;
#endif
};
#ifdef CONFIG_MTK_LVTS_THERMAL_DEBUGFS
#define LVTS_DEBUG_FS_REGS(__reg) \
{ \
.name = __stringify(__reg), \
.offset = __reg(0), \
}
static const struct debugfs_reg32 lvts_regs[] = {
LVTS_DEBUG_FS_REGS(LVTS_MONCTL0),
LVTS_DEBUG_FS_REGS(LVTS_MONCTL1),
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/delay.h`, `linux/debugfs.h`, `linux/init.h`, `linux/interrupt.h`, `linux/iopoll.h`, `linux/kernel.h`.
- Detected declarations: `struct lvts_sensor_data`, `struct lvts_ctrl_data`, `struct lvts_platform_ops`, `struct lvts_data`, `struct lvts_sensor`, `struct lvts_ctrl`, `struct lvts_domain`, `enum lvts_msr_mode`, `function lvts_debugfs_exit`, `function lvts_debugfs_init`.
- 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.