drivers/thermal/broadcom/brcmstb_thermal.c
Source file repositories/reference/linux-study-clean/drivers/thermal/broadcom/brcmstb_thermal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/broadcom/brcmstb_thermal.c- Extension
.c- Size
- 10173 bytes
- Lines
- 380
- 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.
- 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/bitops.hlinux/device.hlinux/err.hlinux/io.hlinux/irqreturn.hlinux/interrupt.hlinux/kernel.hlinux/minmax.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/thermal.h
Detected Declarations
struct avs_tmon_tripstruct brcmstb_thermal_paramsstruct brcmstb_thermal_privenum avs_tmon_trip_typefunction avs_tmon_code_to_tempfunction valuefunction brcmstb_get_tempfunction avs_tmon_trip_enablefunction avs_tmon_get_trip_tempfunction avs_tmon_set_trip_tempfunction avs_tmon_get_intr_tempfunction brcmstb_tmon_irq_threadfunction brcmstb_set_tripsfunction brcmstb_thermal_probe
Annotated Snippet
struct avs_tmon_trip {
/* HW bit to enable the trip */
u32 enable_offs;
u32 enable_mask;
/* HW field to read the trip temperature */
u32 reg_offs;
u32 reg_msk;
int reg_shift;
};
static struct avs_tmon_trip avs_tmon_trips[] = {
/* Trips when temperature is below threshold */
[TMON_TRIP_TYPE_LOW] = {
.enable_offs = AVS_TMON_EN_TEMP_INT_SRCS,
.enable_mask = AVS_TMON_EN_TEMP_INT_SRCS_low,
.reg_offs = AVS_TMON_INT_THRESH,
.reg_msk = AVS_TMON_INT_THRESH_low_msk,
.reg_shift = AVS_TMON_INT_THRESH_low_shift,
},
/* Trips when temperature is above threshold */
[TMON_TRIP_TYPE_HIGH] = {
.enable_offs = AVS_TMON_EN_TEMP_INT_SRCS,
.enable_mask = AVS_TMON_EN_TEMP_INT_SRCS_high,
.reg_offs = AVS_TMON_INT_THRESH,
.reg_msk = AVS_TMON_INT_THRESH_high_msk,
.reg_shift = AVS_TMON_INT_THRESH_high_shift,
},
/* Automatically resets chip when above threshold */
[TMON_TRIP_TYPE_RESET] = {
.enable_offs = AVS_TMON_EN_OVERTEMP_RESET,
.enable_mask = AVS_TMON_EN_OVERTEMP_RESET_msk,
.reg_offs = AVS_TMON_RESET_THRESH,
.reg_msk = AVS_TMON_RESET_THRESH_msk,
.reg_shift = AVS_TMON_RESET_THRESH_shift,
},
};
struct brcmstb_thermal_params {
unsigned int offset;
unsigned int mult;
const struct thermal_zone_device_ops *of_ops;
};
struct brcmstb_thermal_priv {
void __iomem *tmon_base;
struct device *dev;
struct thermal_zone_device *thermal;
/* Process specific thermal parameters used for calculations */
const struct brcmstb_thermal_params *temp_params;
};
/* Convert a HW code to a temperature reading (millidegree celsius) */
static inline int avs_tmon_code_to_temp(struct brcmstb_thermal_priv *priv,
u32 code)
{
int offset = priv->temp_params->offset;
int mult = priv->temp_params->mult;
return (offset - (int)((code & AVS_TMON_TEMP_MASK) * mult));
}
/*
* Convert a temperature value (millidegree celsius) to a HW code
*
* @temp: temperature to convert
* @low: if true, round toward the low side
*/
static inline u32 avs_tmon_temp_to_code(struct brcmstb_thermal_priv *priv,
int temp, bool low)
{
int offset = priv->temp_params->offset;
int mult = priv->temp_params->mult;
if (temp < AVS_TMON_TEMP_MIN)
return AVS_TMON_TEMP_MAX; /* Maximum code value */
if (temp >= offset)
return 0; /* Minimum code value */
if (low)
return (u32)(DIV_ROUND_UP(offset - temp, mult));
else
return (u32)((offset - temp) / mult);
}
static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp)
{
struct brcmstb_thermal_priv *priv = thermal_zone_device_priv(tz);
u32 val;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/device.h`, `linux/err.h`, `linux/io.h`, `linux/irqreturn.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/minmax.h`.
- Detected declarations: `struct avs_tmon_trip`, `struct brcmstb_thermal_params`, `struct brcmstb_thermal_priv`, `enum avs_tmon_trip_type`, `function avs_tmon_code_to_temp`, `function value`, `function brcmstb_get_temp`, `function avs_tmon_trip_enable`, `function avs_tmon_get_trip_temp`, `function avs_tmon_set_trip_temp`.
- Atlas domain: Driver Families / drivers/thermal.
- Implementation status: source implementation candidate.
- 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.