drivers/hwmon/peci/cputemp.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/peci/cputemp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/peci/cputemp.c- Extension
.c- Size
- 14062 bytes
- Lines
- 595
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/auxiliary_bus.hlinux/bitfield.hlinux/bitops.hlinux/hwmon.hlinux/jiffies.hlinux/module.hlinux/peci.hlinux/peci-cpu.hlinux/units.hcommon.h
Detected Declarations
struct resolved_cores_regstruct cpu_infostruct peci_temp_targetstruct peci_cputempenum peci_temp_target_typeenum cputemp_channelsfunction update_temp_targetfunction get_temp_targetfunction dts_validfunction dts_ten_dot_six_to_millidegreefunction formatfunction get_die_tempfunction get_dtsfunction get_core_tempfunction cputemp_read_stringfunction cputemp_readfunction cputemp_is_visiblefunction init_core_maskfunction create_temp_labelfunction for_each_set_bitfunction check_resolved_coresfunction peci_cputemp_probe
Annotated Snippet
struct resolved_cores_reg {
u8 bus;
u8 dev;
u8 func;
u8 offset;
};
struct cpu_info {
struct resolved_cores_reg *reg;
u8 min_peci_revision;
s32 (*thermal_margin_to_millidegree)(u16 val);
};
struct peci_temp_target {
s32 tcontrol;
s32 tthrottle;
s32 tjmax;
struct peci_sensor_state state;
};
enum peci_temp_target_type {
tcontrol_type,
tthrottle_type,
tjmax_type,
crit_hyst_type,
};
struct peci_cputemp {
struct peci_device *peci_dev;
struct device *dev;
const char *name;
const struct cpu_info *gen_info;
struct {
struct peci_temp_target target;
struct peci_sensor_data die;
struct peci_sensor_data dts;
struct peci_sensor_data core[CORE_NUMS_MAX];
} temp;
const char **coretemp_label;
DECLARE_BITMAP(core_mask, CORE_NUMS_MAX);
};
enum cputemp_channels {
channel_die,
channel_dts,
channel_tcontrol,
channel_tthrottle,
channel_tjmax,
channel_core,
};
static const char * const cputemp_label[BASE_CHANNEL_NUMS] = {
"Die",
"DTS",
"Tcontrol",
"Tthrottle",
"Tjmax",
};
static int update_temp_target(struct peci_cputemp *priv)
{
s32 tthrottle_offset, tcontrol_margin;
u32 pcs;
int ret;
if (!peci_sensor_need_update(&priv->temp.target.state))
return 0;
ret = peci_pcs_read(priv->peci_dev, PECI_PCS_TEMP_TARGET, 0, &pcs);
if (ret)
return ret;
priv->temp.target.tjmax =
FIELD_GET(TEMP_TARGET_REF_TEMP_MASK, pcs) * MILLIDEGREE_PER_DEGREE;
tcontrol_margin = FIELD_GET(TEMP_TARGET_FAN_TEMP_MASK, pcs);
tcontrol_margin = sign_extend32(tcontrol_margin, 7) * MILLIDEGREE_PER_DEGREE;
priv->temp.target.tcontrol = priv->temp.target.tjmax - tcontrol_margin;
tthrottle_offset = FIELD_GET(TEMP_TARGET_TJ_OFFSET_MASK, pcs) * MILLIDEGREE_PER_DEGREE;
priv->temp.target.tthrottle = priv->temp.target.tjmax - tthrottle_offset;
peci_sensor_mark_updated(&priv->temp.target.state);
return 0;
}
static int get_temp_target(struct peci_cputemp *priv, enum peci_temp_target_type type, long *val)
{
int ret;
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/bitfield.h`, `linux/bitops.h`, `linux/hwmon.h`, `linux/jiffies.h`, `linux/module.h`, `linux/peci.h`, `linux/peci-cpu.h`.
- Detected declarations: `struct resolved_cores_reg`, `struct cpu_info`, `struct peci_temp_target`, `struct peci_cputemp`, `enum peci_temp_target_type`, `enum cputemp_channels`, `function update_temp_target`, `function get_temp_target`, `function dts_valid`, `function dts_ten_dot_six_to_millidegree`.
- Atlas domain: Driver Families / drivers/hwmon.
- 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.