drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
Source file repositories/reference/linux-study-clean/drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c- Extension
.c- Size
- 8148 bytes
- Lines
- 291
- Domain
- Driver Families
- Bucket
- drivers/thermal
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/pci.hlinux/platform_profile.hprocessor_thermal_device.h
Detected Declarations
enum power_slider_preferencefunction slider_def_balance_setfunction slider_def_balance_getfunction slider_def_offset_setfunction slider_def_offset_getfunction convert_profile_to_power_sliderfunction convert_power_slider_to_profilefunction read_soc_sliderfunction write_soc_sliderfunction set_soc_power_profilefunction power_slider_platform_profile_setfunction power_slider_platform_profile_getfunction power_slider_platform_profile_probefunction proc_thermal_soc_power_slider_addfunction proc_thermal_soc_power_slider_suspendfunction proc_thermal_soc_power_slider_resume
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Processor Thermal Device Interface for Reading and Writing
* SoC Power Slider Values from User Space.
*
* Operation:
* The SOC_EFFICIENCY_SLIDER_0_0_0_MCHBAR register is accessed
* using the MMIO (Memory-Mapped I/O) interface with an MMIO offset of 0x5B38.
* Although this register is 64 bits wide, only bits 7:0 are used,
* and the other bits remain unchanged.
*
* Bit definitions
*
* Bits 2:0 (Slider value):
* The SoC optimizer slider value indicates the system wide energy performance
* hint. The slider has no specific units and ranges from 0 (highest
* performance) to 6 (highest energy efficiency). Value of 7 is reserved.
* Bits 3 : Reserved
* Bits 6:4 (Offset)
* Offset allows the SoC to automatically switch slider position in range
* [slider value (bits 2:0) + offset] to improve power efficiency based on
* internal SoC algorithms.
* Bit 7 (Enable):
* If this bit is set, the SoC Optimization sliders will be processed by the
* SoC firmware.
*
* Copyright (c) 2025, Intel Corporation.
*/
#include <linux/bitfield.h>
#include <linux/pci.h>
#include <linux/platform_profile.h>
#include "processor_thermal_device.h"
#define SOC_POWER_SLIDER_OFFSET 0x5B38
enum power_slider_preference {
SOC_POWER_SLIDER_PERFORMANCE,
SOC_POWER_SLIDER_BALANCE,
SOC_POWER_SLIDER_POWERSAVE,
};
#define SOC_SLIDER_VALUE_MINIMUM 0x00
#define SOC_SLIDER_VALUE_BALANCE 0x03
#define SOC_SLIDER_VALUE_MAXIMUM 0x06
#define SLIDER_MASK GENMASK_ULL(2, 0)
#define SLIDER_ENABLE_BIT 7
static u8 slider_values[] = {
[SOC_POWER_SLIDER_PERFORMANCE] = SOC_SLIDER_VALUE_MINIMUM,
[SOC_POWER_SLIDER_BALANCE] = SOC_SLIDER_VALUE_BALANCE,
[SOC_POWER_SLIDER_POWERSAVE] = SOC_SLIDER_VALUE_MAXIMUM,
};
/* Lock to protect module param updates */
static DEFINE_MUTEX(slider_param_lock);
static int slider_balanced_param = SOC_SLIDER_VALUE_BALANCE;
static int slider_def_balance_set(const char *arg, const struct kernel_param *kp)
{
u8 slider_val;
int ret;
guard(mutex)(&slider_param_lock);
ret = kstrtou8(arg, 16, &slider_val);
if (!ret) {
if (slider_val <= slider_values[SOC_POWER_SLIDER_PERFORMANCE] ||
slider_val >= slider_values[SOC_POWER_SLIDER_POWERSAVE])
return -EINVAL;
slider_balanced_param = slider_val;
}
return ret;
}
static int slider_def_balance_get(char *buf, const struct kernel_param *kp)
{
guard(mutex)(&slider_param_lock);
return sysfs_emit(buf, "%02x\n", slider_values[SOC_POWER_SLIDER_BALANCE]);
}
static const struct kernel_param_ops slider_def_balance_ops = {
.set = slider_def_balance_set,
.get = slider_def_balance_get,
};
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/pci.h`, `linux/platform_profile.h`, `processor_thermal_device.h`.
- Detected declarations: `enum power_slider_preference`, `function slider_def_balance_set`, `function slider_def_balance_get`, `function slider_def_offset_set`, `function slider_def_offset_get`, `function convert_profile_to_power_slider`, `function convert_power_slider_to_profile`, `function read_soc_slider`, `function write_soc_slider`, `function set_soc_power_profile`.
- Atlas domain: Driver Families / drivers/thermal.
- Implementation status: integration implementation candidate.
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.