drivers/thermal/armada_thermal.c
Source file repositories/reference/linux-study-clean/drivers/thermal/armada_thermal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/armada_thermal.c- Extension
.c- Size
- 26502 bytes
- Lines
- 985
- 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/device.hlinux/err.hlinux/io.hlinux/kernel.hlinux/of.hlinux/module.hlinux/delay.hlinux/platform_device.hlinux/of_device.hlinux/thermal.hlinux/iopoll.hlinux/mfd/syscon.hlinux/regmap.hlinux/interrupt.h
Detected Declarations
struct armada_thermal_datastruct armada_thermal_privstruct armada_thermal_datastruct armada_drvdatastruct armada_thermal_sensorenum drvtypefunction armadaxp_initfunction armada370_initfunction armada375_initfunction armada_wait_sensor_validityfunction armada380_initfunction armada_ap80x_initfunction armada_cp110_initfunction armada_is_validfunction armada_enable_overheat_interruptfunction armada_disable_overheat_interruptfunction armada_select_channelfunction armada_read_sensorfunction armada_get_temp_legacyfunction armada_get_tempfunction armada_mc_to_reg_tempfunction armada_mc_to_reg_hystfunction armada_set_overheat_thresholdsfunction armada_overheat_isrfunction armada_overheat_isr_threadfunction armada_thermal_probe_legacyfunction armada_thermal_probe_sysconfunction armada_set_sane_namefunction sourcefunction armada_thermal_probefunction armada_thermal_exit
Annotated Snippet
struct armada_thermal_priv {
struct device *dev;
struct regmap *syscon;
char zone_name[THERMAL_NAME_LENGTH];
/* serialize temperature reads/updates */
struct mutex update_lock;
struct armada_thermal_data *data;
struct thermal_zone_device *overheat_sensor;
int interrupt_source;
int current_channel;
long current_threshold;
long current_hysteresis;
};
struct armada_thermal_data {
/* Initialize the thermal IC */
void (*init)(struct platform_device *pdev,
struct armada_thermal_priv *priv);
/* Formula coeficients: temp = (b - m * reg) / div */
s64 coef_b;
s64 coef_m;
u32 coef_div;
bool inverted;
bool signed_sample;
/* Register shift and mask to access the sensor temperature */
unsigned int temp_shift;
unsigned int temp_mask;
unsigned int thresh_shift;
unsigned int hyst_shift;
unsigned int hyst_mask;
u32 is_valid_bit;
/* Syscon access */
unsigned int syscon_control0_off;
unsigned int syscon_control1_off;
unsigned int syscon_status_off;
unsigned int dfx_irq_cause_off;
unsigned int dfx_irq_mask_off;
unsigned int dfx_overheat_irq;
unsigned int dfx_server_irq_mask_off;
unsigned int dfx_server_irq_en;
/* One sensor is in the thermal IC, the others are in the CPUs if any */
unsigned int cpu_nr;
};
struct armada_drvdata {
enum drvtype {
LEGACY,
SYSCON
} type;
union {
struct armada_thermal_priv *priv;
struct thermal_zone_device *tz;
} data;
};
/*
* struct armada_thermal_sensor - hold the information of one thermal sensor
* @thermal: pointer to the local private structure
* @tzd: pointer to the thermal zone device
* @id: identifier of the thermal sensor
*/
struct armada_thermal_sensor {
struct armada_thermal_priv *priv;
int id;
};
static void armadaxp_init(struct platform_device *pdev,
struct armada_thermal_priv *priv)
{
struct armada_thermal_data *data = priv->data;
u32 reg;
regmap_read(priv->syscon, data->syscon_control1_off, ®);
reg |= PMU_TDC0_OTF_CAL_MASK;
/* Reference calibration value */
reg &= ~PMU_TDC0_REF_CAL_CNT_MASK;
reg |= (0xf1 << PMU_TDC0_REF_CAL_CNT_OFFS);
/* Reset the sensor */
reg |= PMU_TDC0_SW_RST_MASK;
regmap_write(priv->syscon, data->syscon_control1_off, reg);
reg &= ~PMU_TDC0_SW_RST_MASK;
regmap_write(priv->syscon, data->syscon_control1_off, reg);
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/io.h`, `linux/kernel.h`, `linux/of.h`, `linux/module.h`, `linux/delay.h`, `linux/platform_device.h`.
- Detected declarations: `struct armada_thermal_data`, `struct armada_thermal_priv`, `struct armada_thermal_data`, `struct armada_drvdata`, `struct armada_thermal_sensor`, `enum drvtype`, `function armadaxp_init`, `function armada370_init`, `function armada375_init`, `function armada_wait_sensor_validity`.
- 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.