drivers/thermal/qcom/qcom-spmi-temp-alarm.c
Source file repositories/reference/linux-study-clean/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/qcom/qcom-spmi-temp-alarm.c- Extension
.c- Size
- 23371 bytes
- Lines
- 907
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bitfield.hlinux/bitops.hlinux/delay.hlinux/err.hlinux/iio/consumer.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/thermal.h../thermal_hwmon.h
Detected Declarations
struct qpnp_tm_chipstruct spmi_temp_alarm_datastruct qpnp_tm_chipenum overtemp_stagefunction qpnp_tm_readfunction qpnp_tm_writefunction qpnp_tm_decode_tempfunction qpnp_tm_gen1_get_temp_stagefunction qpnp_tm_gen2_get_temp_stagefunction qpnp_tm_lite_get_temp_stagefunction qpnp_tm_update_temp_no_adcfunction qpnp_tm_get_tempfunction qpnp_tm_update_critical_trip_tempfunction qpnp_tm_set_trip_tempfunction qpnp_tm_gen2_rev2_set_temp_threshfunction qpnp_tm_gen2_rev2_set_trip_tempfunction qpnp_tm_lite_set_temp_threshfunction qpnp_tm_lite_set_trip_tempfunction qpnp_tm_isrfunction qpnp_tm_sync_thresholdsfunction qpnp_tm_configure_trip_tempfunction qpnp_tm_gen2_rev2_configure_trip_temps_cbfunction qpnp_tm_gen2_rev2_configure_trip_tempsfunction qpnp_tm_gen2_rev2_sync_thresholdsfunction qpnp_tm_lite_configure_trip_temps_cbfunction qpnp_tm_lite_configure_trip_tempsfunction qpnp_tm_lite_sync_thresholdsfunction qpnp_tm_threshold_initfunction qpnp_tm_initfunction qpnp_tm_probe
Annotated Snippet
struct spmi_temp_alarm_data {
const struct thermal_zone_device_ops *ops;
const long (*temp_map)[THRESH_COUNT][STAGE_COUNT];
int (*sync_thresholds)(struct qpnp_tm_chip *chip);
int (*get_temp_stage)(struct qpnp_tm_chip *chip);
int (*configure_trip_temps)(struct qpnp_tm_chip *chip);
};
struct qpnp_tm_chip {
struct regmap *map;
struct device *dev;
struct thermal_zone_device *tz_dev;
const struct spmi_temp_alarm_data *data;
unsigned int subtype;
long temp;
unsigned int stage;
unsigned int base;
unsigned int ntrips;
/* protects .thresh, .stage and chip registers */
struct mutex lock;
bool initialized;
bool require_stage2_shutdown;
long temp_thresh_map[STAGE_COUNT];
struct iio_channel *adc;
};
/* This array maps from GEN2 alarm state to GEN1 alarm stage */
static const unsigned int alarm_state_map[8] = {0, 1, 1, 2, 2, 3, 3, 3};
static int qpnp_tm_read(struct qpnp_tm_chip *chip, u16 addr, u8 *data)
{
unsigned int val;
int ret;
ret = regmap_read(chip->map, chip->base + addr, &val);
if (ret < 0)
return ret;
*data = val;
return 0;
}
static int qpnp_tm_write(struct qpnp_tm_chip *chip, u16 addr, u8 data)
{
return regmap_write(chip->map, chip->base + addr, data);
}
/**
* qpnp_tm_decode_temp() - return temperature in mC corresponding to the
* specified over-temperature stage
* @chip: Pointer to the qpnp_tm chip
* @stage: Over-temperature stage
*
* Return: temperature in mC
*/
static long qpnp_tm_decode_temp(struct qpnp_tm_chip *chip, unsigned int stage)
{
if (stage == 0 || stage > STAGE_COUNT)
return 0;
return chip->temp_thresh_map[stage - 1];
}
/**
* qpnp_tm_gen1_get_temp_stage() - return over-temperature stage
* @chip: Pointer to the qpnp_tm chip
*
* Return: stage on success, or errno on failure.
*/
static int qpnp_tm_gen1_get_temp_stage(struct qpnp_tm_chip *chip)
{
int ret;
u8 reg;
ret = qpnp_tm_read(chip, QPNP_TM_REG_STATUS, ®);
if (ret < 0)
return ret;
return FIELD_GET(STATUS_GEN1_STAGE_MASK, reg);
}
/**
* qpnp_tm_gen2_get_temp_stage() - return over-temperature stage
* @chip: Pointer to the qpnp_tm chip
*
* Return: stage on success, or errno on failure.
*/
static int qpnp_tm_gen2_get_temp_stage(struct qpnp_tm_chip *chip)
{
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/delay.h`, `linux/err.h`, `linux/iio/consumer.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct qpnp_tm_chip`, `struct spmi_temp_alarm_data`, `struct qpnp_tm_chip`, `enum overtemp_stage`, `function qpnp_tm_read`, `function qpnp_tm_write`, `function qpnp_tm_decode_temp`, `function qpnp_tm_gen1_get_temp_stage`, `function qpnp_tm_gen2_get_temp_stage`, `function qpnp_tm_lite_get_temp_stage`.
- Atlas domain: Driver Families / drivers/thermal.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.