drivers/thermal/qcom/tsens-v1.c

Source file repositories/reference/linux-study-clean/drivers/thermal/qcom/tsens-v1.c

File Facts

System
Linux kernel
Corpus path
drivers/thermal/qcom/tsens-v1.c
Extension
.c
Size
7213 bytes
Lines
259
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

static int __init init_8956(struct tsens_priv *priv) {
	priv->sensor[0].slope = 3313;
	priv->sensor[1].slope = 3275;
	priv->sensor[2].slope = 3320;
	priv->sensor[3].slope = 3246;
	priv->sensor[4].slope = 3279;
	priv->sensor[5].slope = 3257;
	priv->sensor[6].slope = 3234;
	priv->sensor[7].slope = 3269;
	priv->sensor[8].slope = 3255;
	priv->sensor[9].slope = 3239;
	priv->sensor[10].slope = 3286;

	return init_common(priv);
}

static int __init init_tsens_v1_no_rpm(struct tsens_priv *priv)
{
	int i, ret;
	u32 mask = 0;

	ret = init_common(priv);
	if (ret < 0) {
		dev_err(priv->dev, "Init common failed %d\n", ret);
		return ret;
	}

	ret = regmap_field_write(priv->rf[TSENS_SW_RST], 1);
	if (ret) {
		dev_err(priv->dev, "Reset failed\n");
		return ret;
	}

	for (i = 0; i < priv->num_sensors; i++)
		mask |= BIT(priv->sensor[i].hw_id);

	ret = regmap_field_update_bits(priv->rf[SENSOR_EN], mask, mask);
	if (ret) {
		dev_err(priv->dev, "Sensor Enable failed\n");
		return ret;
	}

	ret = regmap_field_write(priv->rf[TSENS_EN], 1);
	if (ret) {
		dev_err(priv->dev, "Enable failed\n");
		return ret;
	}

	ret = regmap_field_write(priv->rf[TSENS_SW_RST], 0);

	return ret;
}

static const struct tsens_ops ops_generic_v1 = {
	.init		= init_common,
	.calibrate	= calibrate_v1,
	.get_temp	= get_temp_tsens_valid,
};

struct tsens_plat_data data_tsens_v1 = {
	.ops		= &ops_generic_v1,
	.feat		= &tsens_v1_feat,
	.fields	= tsens_v1_regfields,
};

static const struct tsens_ops ops_common = {
	.init		= init_common,
	.calibrate	= tsens_calibrate_common,
	.get_temp	= get_temp_tsens_valid,
};

struct tsens_plat_data data_8937 = {
	.num_sensors	= 11,
	.ops		= &ops_common,
	.feat		= &tsens_v1_feat,
	.fields		= tsens_v1_regfields,
};

static const struct tsens_ops ops_8956 = {
	.init		= init_8956,
	.calibrate	= tsens_calibrate_common,
	.get_temp	= get_temp_tsens_valid,
};

struct tsens_plat_data data_8956 = {
	.num_sensors	= 11,
	.ops		= &ops_8956,
	.feat		= &tsens_v1_feat,
	.fields		= tsens_v1_regfields,
};

Annotation

Implementation Notes