drivers/thermal/mediatek/auxadc_thermal.c
Source file repositories/reference/linux-study-clean/drivers/thermal/mediatek/auxadc_thermal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/mediatek/auxadc_thermal.c- Extension
.c- Size
- 36490 bytes
- Lines
- 1317
- 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.
- 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/delay.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/nvmem-consumer.hlinux/of.hlinux/of_address.hlinux/platform_device.hlinux/slab.hlinux/io.hlinux/thermal.hlinux/reset.hlinux/types.h../thermal_hwmon.h
Detected Declarations
struct mtk_thermalstruct thermal_bank_cfgstruct mtk_thermal_bankstruct mtk_thermal_datastruct mtk_thermalenum mtk_thermal_versionfunction mtk_thermal_temp_is_validfunction raw_to_mcelsius_v1function raw_to_mcelsius_v2function raw_to_mcelsius_v3function mtk_thermal_get_bankfunction mtk_thermal_put_bankfunction mtk_thermal_bank_temperaturefunction mtk_read_tempfunction mtk_thermal_init_bankfunction of_get_phys_basefunction mtk_thermal_extract_efuse_v1function mtk_thermal_extract_efuse_v2function mtk_thermal_extract_efuse_v3function mtk_thermal_get_calibration_datafunction mtk_thermal_turn_on_bufferfunction mtk_thermal_release_periodic_tsfunction mtk_thermal_probe
Annotated Snippet
struct thermal_bank_cfg {
unsigned int num_sensors;
const int *sensors;
};
struct mtk_thermal_bank {
struct mtk_thermal *mt;
int id;
};
struct mtk_thermal_data {
s32 num_banks;
s32 num_sensors;
s32 auxadc_channel;
const int *vts_index;
const int *sensor_mux_values;
const int *msr;
const int *adcpnp;
const int cali_val;
const int num_controller;
const int *controller_offset;
bool need_switch_bank;
struct thermal_bank_cfg bank_data[MAX_NUM_ZONES];
enum mtk_thermal_version version;
u32 apmixed_buffer_ctl_reg;
u32 apmixed_buffer_ctl_mask;
u32 apmixed_buffer_ctl_set;
};
struct mtk_thermal {
struct device *dev;
void __iomem *thermal_base;
struct clk *clk_peri_therm;
struct clk *clk_auxadc;
/* lock: for getting and putting banks */
struct mutex lock;
/* Calibration values */
s32 adc_ge;
s32 adc_oe;
s32 degc_cali;
s32 o_slope;
s32 o_slope_sign;
s32 vts[MAX_NUM_VTS];
const struct mtk_thermal_data *conf;
struct mtk_thermal_bank banks[MAX_NUM_ZONES];
int (*raw_to_mcelsius)(struct mtk_thermal *mt, int sensno, s32 raw);
};
/* MT8183 thermal sensor data */
static const int mt8183_bank_data[MT8183_NUM_SENSORS] = {
MT8183_TS1, MT8183_TS2, MT8183_TS3, MT8183_TS4, MT8183_TS5, MT8183_TSABB
};
static const int mt8183_msr[MT8183_NUM_SENSORS_PER_ZONE] = {
TEMP_MSR0_1, TEMP_MSR1_1, TEMP_MSR2_1, TEMP_MSR1, TEMP_MSR0, TEMP_MSR3_1
};
static const int mt8183_adcpnp[MT8183_NUM_SENSORS_PER_ZONE] = {
TEMP_ADCPNP0_1, TEMP_ADCPNP1_1, TEMP_ADCPNP2_1,
TEMP_ADCPNP1, TEMP_ADCPNP0, TEMP_ADCPNP3_1
};
static const int mt8183_mux_values[MT8183_NUM_SENSORS] = { 0, 1, 2, 3, 4, 0 };
static const int mt8183_tc_offset[MT8183_NUM_CONTROLLER] = {0x0, 0x100};
static const int mt8183_vts_index[MT8183_NUM_SENSORS] = {
VTS1, VTS2, VTS3, VTS4, VTS5, VTSABB
};
/* MT8173 thermal sensor data */
static const int mt8173_bank_data[MT8173_NUM_ZONES][3] = {
{ MT8173_TS2, MT8173_TS3 },
{ MT8173_TS2, MT8173_TS4 },
{ MT8173_TS1, MT8173_TS2, MT8173_TSABB },
{ MT8173_TS2 },
};
static const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = {
TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR3
};
static const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = {
TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2, TEMP_ADCPNP3
};
static const int mt8173_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 };
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/nvmem-consumer.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `struct mtk_thermal`, `struct thermal_bank_cfg`, `struct mtk_thermal_bank`, `struct mtk_thermal_data`, `struct mtk_thermal`, `enum mtk_thermal_version`, `function mtk_thermal_temp_is_valid`, `function raw_to_mcelsius_v1`, `function raw_to_mcelsius_v2`, `function raw_to_mcelsius_v3`.
- 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.
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.