drivers/thermal/mediatek/lvts_thermal.c

Source file repositories/reference/linux-study-clean/drivers/thermal/mediatek/lvts_thermal.c

File Facts

System
Linux kernel
Corpus path
drivers/thermal/mediatek/lvts_thermal.c
Extension
.c
Size
61286 bytes
Lines
2208
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

struct lvts_sensor_data {
	int dt_id;
	u8 cal_offsets[LVTS_MAX_CAL_OFFSETS];
};

struct lvts_ctrl_data {
	struct lvts_sensor_data lvts_sensor[LVTS_SENSOR_MAX];
	u8 valid_sensor_mask;
	int offset;
	enum lvts_msr_mode mode;
};

#define VALID_SENSOR_MAP(s0, s1, s2, s3) \
	.valid_sensor_mask = (((s0) ? BIT(0) : 0) | \
			      ((s1) ? BIT(1) : 0) | \
			      ((s2) ? BIT(2) : 0) | \
			      ((s3) ? BIT(3) : 0))

#define lvts_for_each_valid_sensor(i, lvts_ctrl) \
	for ((i) = 0; (i) < LVTS_SENSOR_MAX; (i)++) \
		if (!((lvts_ctrl)->valid_sensor_mask & BIT(i))) \
			continue; \
		else

struct lvts_platform_ops {
	int (*lvts_raw_to_temp)(u32 raw_temp, int temp_factor);
	u32 (*lvts_temp_to_raw)(int temperature, int temp_factor);
};

struct lvts_data {
	const struct lvts_ctrl_data *lvts_ctrl;
	const struct lvts_platform_ops *ops;
	const u32 *conn_cmd;
	const u32 *init_cmd;
	int num_cal_offsets;
	int num_lvts_ctrl;
	int num_conn_cmd;
	int num_init_cmd;
	int temp_factor;
	int temp_offset;
	int gt_calib_bit_offset;
	unsigned int def_calibration;
	u16 msr_offset;
};

struct lvts_sensor {
	struct thermal_zone_device *tz;
	void __iomem *msr;
	void __iomem *base;
	int id;
	int dt_id;
	int low_thresh;
	int high_thresh;
};

struct lvts_ctrl {
	struct lvts_sensor sensors[LVTS_SENSOR_MAX];
	const struct lvts_data *lvts_data;
	u32 calibration[LVTS_SENSOR_MAX];
	u8 valid_sensor_mask;
	int mode;
	void __iomem *base;
	int low_thresh;
	int high_thresh;
};

struct lvts_domain {
	struct lvts_ctrl *lvts_ctrl;
	struct reset_control *reset;
	struct clk *clk;
	int num_lvts_ctrl;
	void __iomem *base;
	size_t calib_len;
	u8 *calib;
#ifdef CONFIG_DEBUG_FS
	struct dentry *dom_dentry;
#endif
};

#ifdef CONFIG_MTK_LVTS_THERMAL_DEBUGFS

#define LVTS_DEBUG_FS_REGS(__reg)		\
{						\
	.name = __stringify(__reg),		\
	.offset = __reg(0),			\
}

static const struct debugfs_reg32 lvts_regs[] = {
	LVTS_DEBUG_FS_REGS(LVTS_MONCTL0),
	LVTS_DEBUG_FS_REGS(LVTS_MONCTL1),

Annotation

Implementation Notes