drivers/thermal/qcom/tsens-v2.c
Source file repositories/reference/linux-study-clean/drivers/thermal/qcom/tsens-v2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/qcom/tsens-v2.c- Extension
.c- Size
- 9453 bytes
- Lines
- 317
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bitops.hlinux/nvmem-consumer.hlinux/regmap.htsens.h
Detected Declarations
function tsens_v2_calibrate_sensorfunction tsens_v2_calibrationfunction init_tsens_v2_no_rpm
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
* Copyright (c) 2018, Linaro Limited
*/
#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/nvmem-consumer.h>
#include <linux/regmap.h>
#include "tsens.h"
/* ----- SROT ------ */
#define SROT_HW_VER_OFF 0x0000
#define SROT_CTRL_OFF 0x0004
#define SROT_MEASURE_PERIOD 0x0008
#define SROT_Sn_CONVERSION 0x0060
#define V2_SHIFT_DEFAULT 0x0003
#define V2_SLOPE_DEFAULT 0x0cd0
#define V2_CZERO_DEFAULT 0x016a
#define ONE_PT_SLOPE 0x0cd0
#define TWO_PT_SHIFTED_GAIN 921600
#define ONE_PT_CZERO_CONST 94
#define SW_RST_DEASSERT 0x0
#define SW_RST_ASSERT 0x1
#define MEASURE_PERIOD_2mSEC 0x1
#define RESULT_FORMAT_TEMP 0x1
#define TSENS_ENABLE 0x1
#define SENSOR_CONVERSION(n) (((n) * 4) + SROT_Sn_CONVERSION)
#define CONVERSION_SHIFT_MASK GENMASK(24, 23)
#define CONVERSION_SLOPE_MASK GENMASK(22, 10)
#define CONVERSION_CZERO_MASK GENMASK(9, 0)
/* ----- TM ------ */
#define TM_INT_EN_OFF 0x0004
#define TM_UPPER_LOWER_INT_STATUS_OFF 0x0008
#define TM_UPPER_LOWER_INT_CLEAR_OFF 0x000c
#define TM_UPPER_LOWER_INT_MASK_OFF 0x0010
#define TM_CRITICAL_INT_STATUS_OFF 0x0014
#define TM_CRITICAL_INT_CLEAR_OFF 0x0018
#define TM_CRITICAL_INT_MASK_OFF 0x001c
#define TM_Sn_UPPER_LOWER_THRESHOLD_OFF 0x0020
#define TM_Sn_CRITICAL_THRESHOLD_OFF 0x0060
#define TM_Sn_STATUS_OFF 0x00a0
#define TM_TRDY_OFF 0x00e4
#define TM_WDOG_LOG_OFF 0x013c
/* v2.x: 8996, 8998, sdm845 */
static struct tsens_features tsens_v2_feat = {
.ver_major = VER_2_X,
.crit_int = 1,
.combo_int = 0,
.adc = 0,
.srot_split = 1,
.max_sensors = 16,
.trip_min_temp = -40000,
.trip_max_temp = 120000,
};
static struct tsens_features ipq8074_feat = {
.ver_major = VER_2_X,
.crit_int = 1,
.combo_int = 1,
.adc = 0,
.srot_split = 1,
.max_sensors = 16,
.trip_min_temp = 0,
.trip_max_temp = 204000,
};
static struct tsens_features ipq5332_feat = {
.ver_major = VER_2_X_NO_RPM,
.crit_int = 1,
.combo_int = 1,
.adc = 0,
.srot_split = 1,
.max_sensors = 16,
.trip_min_temp = 0,
.trip_max_temp = 204000,
};
static const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = {
/* ----- SROT ------ */
/* VERSION */
[VER_MAJOR] = REG_FIELD(SROT_HW_VER_OFF, 28, 31),
[VER_MINOR] = REG_FIELD(SROT_HW_VER_OFF, 16, 27),
[VER_STEP] = REG_FIELD(SROT_HW_VER_OFF, 0, 15),
/* CTRL_OFF */
[TSENS_EN] = REG_FIELD(SROT_CTRL_OFF, 0, 0),
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/nvmem-consumer.h`, `linux/regmap.h`, `tsens.h`.
- Detected declarations: `function tsens_v2_calibrate_sensor`, `function tsens_v2_calibration`, `function init_tsens_v2_no_rpm`.
- Atlas domain: Driver Families / drivers/thermal.
- Implementation status: source implementation candidate.
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.