drivers/thermal/rockchip_thermal.c
Source file repositories/reference/linux-study-clean/drivers/thermal/rockchip_thermal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/rockchip_thermal.c- Extension
.c- Size
- 52510 bytes
- Lines
- 1897
- 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/clk.hlinux/delay.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/nvmem-consumer.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hlinux/regmap.hlinux/reset.hlinux/thermal.hlinux/mfd/syscon.hlinux/pinctrl/consumer.hthermal_hwmon.h
Detected Declarations
struct chip_tsadc_tablestruct rockchip_tsadc_chipstruct rockchip_thermal_sensorstruct rockchip_thermal_datastruct tsadc_tableenum tshut_modeenum tshut_polarityenum adc_sort_modefunction rk_tsadcv2_temp_to_codefunction rk_tsadcv2_code_to_tempfunction rk_tsadcv2_initializefunction rk_tsadcv3_initializefunction rk_tsadcv4_initializefunction rk_tsadcv7_initializefunction rk_tsadcv8_initializefunction rk_tsadcv2_irq_ackfunction rk_tsadcv3_irq_ackfunction rk_tsadcv4_irq_ackfunction rk_tsadcv2_controlfunction rk_tsadcv3_controlfunction rk_tsadcv4_controlfunction rk_tsadcv2_get_tempfunction rk_tsadcv4_get_tempfunction rk_tsadcv2_alarm_tempfunction rk_tsadcv3_alarm_tempfunction rk_tsadcv2_tshut_tempfunction rk_tsadcv3_tshut_tempfunction rk_tsadcv2_tshut_modefunction rk_tsadcv4_tshut_modefunction rk_tsadcv2_get_trim_codefunction rockchip_thermal_toggle_sensorfunction rockchip_thermal_alarm_irq_threadfunction rockchip_thermal_set_tripsfunction rockchip_thermal_get_tempfunction rockchip_get_efuse_valuefunction rockchip_get_trim_configurationfunction rockchip_configure_from_dtfunction rockchip_thermal_register_sensorfunction rockchip_thermal_reset_controllerfunction rockchip_thermal_probefunction for_each_available_child_of_nodefunction rockchip_thermal_removefunction rockchip_thermal_suspendfunction rockchip_thermal_resume
Annotated Snippet
struct chip_tsadc_table {
const struct tsadc_table *id;
unsigned int length;
u32 data_mask;
enum adc_sort_mode mode;
};
/**
* struct rockchip_tsadc_chip - hold the private data of tsadc chip
* @chn_offset: the channel offset of the first channel
* @chn_num: the channel number of tsadc chip
* @trim_slope: used to convert the trim code to a temperature in millicelsius
* @tshut_temp: the hardware-controlled shutdown temperature value, with no trim
* @tshut_mode: the hardware-controlled shutdown mode (0:CRU 1:GPIO)
* @tshut_polarity: the hardware-controlled active polarity (0:LOW 1:HIGH)
* @grf_required: true, if a GRF is required for proper functionality
* @initialize: SoC special initialize tsadc controller method
* @irq_ack: clear the interrupt
* @control: enable/disable method for the tsadc controller
* @get_temp: get the raw temperature, unadjusted by trim
* @set_alarm_temp: set the high temperature interrupt
* @set_tshut_temp: set the hardware-controlled shutdown temperature
* @set_tshut_mode: set the hardware-controlled shutdown mode
* @get_trim_code: convert a hardware temperature code to one adjusted for by trim
* @table: the chip-specific conversion table
*/
struct rockchip_tsadc_chip {
/* The sensor id of chip correspond to the ADC channel */
int chn_offset;
int chn_num;
/* Used to convert trim code to trim temp */
int trim_slope;
/* The hardware-controlled tshut property */
int tshut_temp;
enum tshut_mode tshut_mode;
enum tshut_polarity tshut_polarity;
/* GRF availability */
bool grf_required;
/* Chip-wide methods */
void (*initialize)(struct regmap *grf,
void __iomem *reg, enum tshut_polarity p);
void (*irq_ack)(void __iomem *reg);
void (*control)(void __iomem *reg, bool on);
/* Per-sensor methods */
int (*get_temp)(const struct chip_tsadc_table *table,
int chn, void __iomem *reg, int *temp);
int (*set_alarm_temp)(const struct chip_tsadc_table *table,
int chn, void __iomem *reg, int temp);
int (*set_tshut_temp)(const struct chip_tsadc_table *table,
int chn, void __iomem *reg, int temp);
void (*set_tshut_mode)(int chn, void __iomem *reg, enum tshut_mode m);
int (*get_trim_code)(const struct chip_tsadc_table *table,
int code, int trim_base, int trim_base_frac);
/* Per-table methods */
struct chip_tsadc_table table;
};
/**
* struct rockchip_thermal_sensor - hold the information of thermal sensor
* @thermal: pointer to the platform/configuration data
* @tzd: pointer to a thermal zone
* @of_node: pointer to the device_node representing this sensor, if any
* @id: identifier of the thermal sensor
* @trim_temp: per-sensor trim temperature value
*/
struct rockchip_thermal_sensor {
struct rockchip_thermal_data *thermal;
struct thermal_zone_device *tzd;
struct device_node *of_node;
int id;
int trim_temp;
};
/**
* struct rockchip_thermal_data - hold the private data of thermal driver
* @chip: pointer to the platform/configuration data
* @pdev: platform device of thermal
* @reset: the reset controller of tsadc
* @sensors: array of thermal sensors
* @clk: the controller clock is divided by the exteral 24MHz
* @pclk: the advanced peripherals bus clock
* @grf: the general register file will be used to do static set by software
* @regs: the base address of tsadc controller
* @trim_base: major component of sensor trim value, in Celsius
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/nvmem-consumer.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `struct chip_tsadc_table`, `struct rockchip_tsadc_chip`, `struct rockchip_thermal_sensor`, `struct rockchip_thermal_data`, `struct tsadc_table`, `enum tshut_mode`, `enum tshut_polarity`, `enum adc_sort_mode`, `function rk_tsadcv2_temp_to_code`, `function rk_tsadcv2_code_to_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.