drivers/thermal/qcom/tsens-8960.c
Source file repositories/reference/linux-study-clean/drivers/thermal/qcom/tsens-8960.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/qcom/tsens-8960.c- Extension
.c- Size
- 6953 bytes
- Lines
- 286
- 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/platform_device.hlinux/delay.hlinux/bitops.hlinux/regmap.hlinux/thermal.htsens.h
Detected Declarations
function suspend_8960function resume_8960function enable_8960function disable_8960function calibrate_8960
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
*/
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/bitops.h>
#include <linux/regmap.h>
#include <linux/thermal.h>
#include "tsens.h"
#define CONFIG_ADDR 0x3640
#define CONFIG_ADDR_8660 0x3620
/* CONFIG_ADDR bitmasks */
#define CONFIG 0x9b
#define CONFIG_MASK 0xf
#define CONFIG_8660 1
#define CONFIG_SHIFT_8660 28
#define CONFIG_MASK_8660 (3 << CONFIG_SHIFT_8660)
#define CNTL_ADDR 0x3620
/* CNTL_ADDR bitmasks */
#define EN BIT(0)
#define SW_RST BIT(1)
#define MEASURE_PERIOD BIT(18)
#define SLP_CLK_ENA BIT(26)
#define SLP_CLK_ENA_8660 BIT(24)
#define SENSOR0_SHIFT 3
#define THRESHOLD_ADDR 0x3624
#define INT_STATUS_ADDR 0x363c
#define S0_STATUS_OFF 0x3628
#define S1_STATUS_OFF 0x362c
#define S2_STATUS_OFF 0x3630
#define S3_STATUS_OFF 0x3634
#define S4_STATUS_OFF 0x3638
#define S5_STATUS_OFF 0x3664 /* Sensors 5-10 found on apq8064/msm8960 */
#define S6_STATUS_OFF 0x3668
#define S7_STATUS_OFF 0x366c
#define S8_STATUS_OFF 0x3670
#define S9_STATUS_OFF 0x3674
#define S10_STATUS_OFF 0x3678
/* Original slope - 350 to compensate mC to C inaccuracy */
static u32 tsens_msm8960_slope[] = {
826, 826, 804, 826,
761, 782, 782, 849,
782, 849, 782
};
static int suspend_8960(struct tsens_priv *priv)
{
int ret;
unsigned int mask;
struct regmap *map = priv->tm_map;
ret = regmap_read(map, THRESHOLD_ADDR, &priv->ctx.threshold);
if (ret)
return ret;
ret = regmap_read(map, CNTL_ADDR, &priv->ctx.control);
if (ret)
return ret;
if (priv->num_sensors > 1)
mask = SLP_CLK_ENA | EN;
else
mask = SLP_CLK_ENA_8660 | EN;
ret = regmap_update_bits(map, CNTL_ADDR, mask, 0);
if (ret)
return ret;
return 0;
}
static int resume_8960(struct tsens_priv *priv)
{
int ret;
struct regmap *map = priv->tm_map;
ret = regmap_update_bits(map, CNTL_ADDR, SW_RST, SW_RST);
if (ret)
return ret;
/*
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/delay.h`, `linux/bitops.h`, `linux/regmap.h`, `linux/thermal.h`, `tsens.h`.
- Detected declarations: `function suspend_8960`, `function resume_8960`, `function enable_8960`, `function disable_8960`, `function calibrate_8960`.
- 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.