drivers/thermal/renesas/rzg3e_thermal.c
Source file repositories/reference/linux-study-clean/drivers/thermal/renesas/rzg3e_thermal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/renesas/rzg3e_thermal.c- Extension
.c- Size
- 15347 bytes
- Lines
- 572
- 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/arm-smccc.hlinux/clk.hlinux/cleanup.hlinux/delay.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/reset.hlinux/thermal.hlinux/units.h../thermal_hwmon.h
Detected Declarations
struct rzg3e_thermal_privstruct rzg3e_thermal_infostruct rzg3e_thermal_privfunction rzg3e_thermal_power_onfunction rzg3e_thermal_power_offfunction Tfunction rzg3e_thermal_temp_to_codefunction rzg3e_thermal_get_tempfunction rzg3e_thermal_set_tripsfunction rzg3e_thermal_irq_threadfunction rzg3e_thermal_irqfunction rzg3e_thermal_get_syscon_trimfunction rzg3e_thermal_get_smc_trimfunction rzg3e_thermal_probefunction rzg3e_thermal_runtime_suspendfunction rzg3e_thermal_runtime_resumefunction rzg3e_thermal_suspendfunction rzg3e_thermal_resume
Annotated Snippet
struct rzg3e_thermal_info {
int (*get_trim)(struct rzg3e_thermal_priv *priv);
int temp_d_mc;
int temp_e_mc;
};
/**
* struct rzg3e_thermal_priv - RZ/G3E TSU private data
* @base: TSU register base
* @dev: device pointer
* @syscon: regmap for calibration values
* @zone: thermal zone device
* @rstc: reset control
* @info: chip type specific information
* @trmval0: calibration value 0 (b)
* @trmval1: calibration value 1 (c)
* @lock: protects hardware access during conversions
*/
struct rzg3e_thermal_priv {
void __iomem *base;
struct device *dev;
struct thermal_zone_device *zone;
struct reset_control *rstc;
const struct rzg3e_thermal_info *info;
u16 trmval0;
u16 trmval1;
struct mutex lock;
};
static int rzg3e_thermal_power_on(struct rzg3e_thermal_priv *priv)
{
u32 val;
int ret;
/* Clear any pending interrupts */
writel(TSU_SICR_ADCLR | TSU_SICR_CMPCLR, priv->base + TSU_SICR);
/* Disable all interrupts during setup */
writel(0, priv->base + TSU_SIER);
/*
* Power-on sequence per datasheet 7.11.9.1:
* SOC_TS_EN must be set at same time or before EN_TS and ADC_PD_TS
*/
val = TSU_SSUSR_SOC_TS_EN | TSU_SSUSR_EN_TS;
writel(val, priv->base + TSU_SSUSR);
/* Wait for sensor stabilization per datasheet 7.11.7.1 */
usleep_range(TSU_POWERUP_TIME_US, TSU_POWERUP_TIME_US + 10);
/* Configure for average mode with 8 samples */
val = TSU_SOSR1_OUTSEL | TSU_SOSR1_ADCT_8;
writel(val, priv->base + TSU_SOSR1);
/* Ensure we're in single scan mode (default) */
val = readl(priv->base + TSU_SOSR1);
if (val & TSU_SOSR1_ADCS) {
dev_err(priv->dev, "Invalid scan mode setting\n");
return -EINVAL;
}
/* Wait for any ongoing conversion to complete */
ret = readl_poll_timeout(priv->base + TSU_SSR, val,
!(val & TSU_SSR_CONV),
TSU_POLL_DELAY_US,
USEC_PER_MSEC);
if (ret) {
dev_err(priv->dev, "Timeout waiting for conversion\n");
return ret;
}
return 0;
}
static void rzg3e_thermal_power_off(struct rzg3e_thermal_priv *priv)
{
/* Disable all interrupts */
writel(0, priv->base + TSU_SIER);
/* Clear pending interrupts */
writel(TSU_SICR_ADCLR | TSU_SICR_CMPCLR, priv->base + TSU_SICR);
/* Power down sequence per datasheet */
writel(TSU_SSUSR_ADC_PD_TS, priv->base + TSU_SSUSR);
}
/*
* Convert 12-bit sensor code to temperature in millicelsius
* Formula from datasheet 7.11.7.8:
* T(°C) = ((e - d) / (c - b)) * (a - b) + d
Annotation
- Immediate include surface: `linux/arm-smccc.h`, `linux/clk.h`, `linux/cleanup.h`, `linux/delay.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/iopoll.h`.
- Detected declarations: `struct rzg3e_thermal_priv`, `struct rzg3e_thermal_info`, `struct rzg3e_thermal_priv`, `function rzg3e_thermal_power_on`, `function rzg3e_thermal_power_off`, `function T`, `function rzg3e_thermal_temp_to_code`, `function rzg3e_thermal_get_temp`, `function rzg3e_thermal_set_trips`, `function rzg3e_thermal_irq_thread`.
- 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.