drivers/thermal/qcom/tsens.c
Source file repositories/reference/linux-study-clean/drivers/thermal/qcom/tsens.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/qcom/tsens.c- Extension
.c- Size
- 37728 bytes
- Lines
- 1482
- 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/debugfs.hlinux/err.hlinux/io.hlinux/module.hlinux/nvmem-consumer.hlinux/of.hlinux/of_address.hlinux/of_platform.hlinux/mfd/syscon.hlinux/platform_device.hlinux/pm.hlinux/regmap.hlinux/slab.hlinux/suspend.hlinux/thermal.h../thermal_hwmon.htsens.h
Detected Declarations
struct tsens_irq_datafunction tsens_read_calibrationfunction tsens_calibrate_nvmemfunction tsens_calibrate_commonfunction tsens_read_cellfunction tsens_read_calibration_legacyfunction compute_intercept_slopefunction degc_to_codefunction code_to_degcfunction tsens_read_tempfunction tsens_hw_to_mCfunction tsens_mC_to_hwfunction tsens_versionfunction tsens_set_interrupt_v1function tsens_set_interrupt_v2function tsens_set_interruptfunction tsens_threshold_violatedfunction tsens_read_irq_statefunction masked_irqfunction tsens_critical_irq_threadfunction tsens_irq_threadfunction tsens_combined_irq_threadfunction tsens_set_tripsfunction tsens_enable_irqfunction tsens_disable_irqfunction get_temp_tsens_validfunction get_temp_commonfunction dbg_sensors_showfunction dbg_version_showfunction tsens_debug_initfunction tsens_debug_initfunction init_commonfunction tsens_get_tempfunction tsens_suspendfunction tsens_resumefunction tsens_register_irqfunction tsens_reinitfunction tsens_suspend_commonfunction tsens_resume_commonfunction tsens_registerfunction tsens_probefunction tsens_remove
Annotated Snippet
struct tsens_irq_data {
u32 up_viol;
int up_thresh;
u32 up_irq_mask;
u32 up_irq_clear;
u32 low_viol;
int low_thresh;
u32 low_irq_mask;
u32 low_irq_clear;
u32 crit_viol;
u32 crit_thresh;
u32 crit_irq_mask;
u32 crit_irq_clear;
};
char *qfprom_read(struct device *dev, const char *cname)
{
struct nvmem_cell *cell;
ssize_t data;
char *ret;
cell = nvmem_cell_get(dev, cname);
if (IS_ERR(cell))
return ERR_CAST(cell);
ret = nvmem_cell_read(cell, &data);
nvmem_cell_put(cell);
return ret;
}
int tsens_read_calibration(struct tsens_priv *priv, int shift, u32 *p1, u32 *p2, bool backup)
{
u32 mode;
u32 base1, base2;
char name[] = "sXX_pY_backup"; /* s10_p1_backup */
int i, ret;
if (priv->num_sensors > MAX_SENSORS)
return -EINVAL;
ret = snprintf(name, sizeof(name), "mode%s", backup ? "_backup" : "");
if (ret < 0)
return ret;
ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &mode);
if (ret == -ENOENT)
dev_warn(priv->dev, "Please migrate to separate nvmem cells for calibration data\n");
if (ret < 0)
return ret;
dev_dbg(priv->dev, "calibration mode is %d\n", mode);
ret = snprintf(name, sizeof(name), "base1%s", backup ? "_backup" : "");
if (ret < 0)
return ret;
ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &base1);
if (ret < 0)
return ret;
ret = snprintf(name, sizeof(name), "base2%s", backup ? "_backup" : "");
if (ret < 0)
return ret;
ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &base2);
if (ret < 0)
return ret;
for (i = 0; i < priv->num_sensors; i++) {
ret = snprintf(name, sizeof(name), "s%d_p1%s", priv->sensor[i].hw_id,
backup ? "_backup" : "");
if (ret < 0)
return ret;
ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &p1[i]);
if (ret)
return ret;
ret = snprintf(name, sizeof(name), "s%d_p2%s", priv->sensor[i].hw_id,
backup ? "_backup" : "");
if (ret < 0)
return ret;
ret = nvmem_cell_read_variable_le_u32(priv->dev, name, &p2[i]);
if (ret)
return ret;
}
switch (mode) {
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/err.h`, `linux/io.h`, `linux/module.h`, `linux/nvmem-consumer.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_platform.h`.
- Detected declarations: `struct tsens_irq_data`, `function tsens_read_calibration`, `function tsens_calibrate_nvmem`, `function tsens_calibrate_common`, `function tsens_read_cell`, `function tsens_read_calibration_legacy`, `function compute_intercept_slope`, `function degc_to_code`, `function code_to_degc`, `function tsens_read_temp`.
- 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.