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.

Dependency Surface

Detected Declarations

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

Implementation Notes