drivers/hwmon/ltc4282.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/ltc4282.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/ltc4282.c- Extension
.c- Size
- 45534 bytes
- Lines
- 1711
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- 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.
- 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/bitfield.hlinux/cleanup.hlinux/clk.hlinux/clk-provider.hlinux/debugfs.hlinux/delay.hlinux/device.hlinux/hwmon.hlinux/i2c.hlinux/math.hlinux/minmax.hlinux/module.hlinux/mod_devicetable.hlinux/regmap.hlinux/property.hlinux/string.hlinux/units.hlinux/util_macros.h
Detected Declarations
struct ltc4282_cachestruct ltc4282_statefunction ltc4282_set_ratefunction ltc4282_determine_ratefunction ltc4282_recalc_ratefunction ltc4282_disablefunction ltc4282_read_voltage_wordfunction ltc4282_read_voltage_byte_cachedfunction ltc4282_read_voltage_bytefunction __ltc4282_read_alarmfunction ltc4282_read_alarmfunction ltc4282_vdd_source_read_infunction ltc4282_vdd_source_read_histfunction ltc4282_vdd_source_read_limfunction ltc4282_vdd_source_read_almfunction ltc4282_read_infunction ltc4282_read_current_wordfunction ltc4282_read_current_bytefunction ltc4282_read_currfunction ltc4282_read_power_wordfunction ltc4282_read_power_bytefunction ltc4282_read_energyfunction ltc4282_read_powerfunction ltc4282_readfunction ltc4282_write_power_bytefunction ltc4282_write_power_wordfunction __ltc4282_in_write_historyfunction ltc4282_in_write_historyfunction ltc4282_power_reset_histfunction ltc4282_write_powerfunction ltc4282_write_voltage_byte_cachedfunction ltc4282_write_voltage_bytefunction ltc4282_cache_historyfunction ltc4282_cache_syncfunction ltc4282_vdd_source_write_limfunction ltc4282_vdd_source_reset_histfunction runningfunction ltc4282_write_infunction ltc4282_curr_reset_histfunction ltc4282_write_currfunction ltc4282_energy_enable_setfunction ltc4282_writefunction ltc4282_in_is_visiblefunction ltc4282_curr_is_visiblefunction ltc4282_power_is_visiblefunction ltc4282_is_visiblefunction ltc4282_read_labelsfunction ltc428_clk_provider_setup
Annotated Snippet
struct ltc4282_cache {
u32 in_max_raw;
u32 in_min_raw;
long in_highest;
long in_lowest;
bool en;
};
struct ltc4282_state {
struct regmap *map;
struct clk_hw clk_hw;
/*
* Used to cache values for VDD/VSOURCE depending which will be used
* when hwmon is not enabled for that channel. Needed because they share
* the same registers.
*/
struct ltc4282_cache in0_1_cache[LTC4282_CHAN_VGPIO];
u32 vsense_max;
long power_max;
u32 rsense;
u16 vdd;
u16 vfs_out;
bool energy_en;
};
enum {
LTC4282_CLKOUT_NONE,
LTC4282_CLKOUT_INT,
LTC4282_CLKOUT_TICK,
};
static int ltc4282_set_rate(struct clk_hw *hw,
unsigned long rate, unsigned long parent_rate)
{
struct ltc4282_state *st = container_of(hw, struct ltc4282_state,
clk_hw);
u32 val = LTC4282_CLKOUT_INT;
if (rate == LTC4282_CLKOUT_CNV)
val = LTC4282_CLKOUT_TICK;
return regmap_update_bits(st->map, LTC4282_CLK_DIV, LTC4282_CLKOUT_MASK,
FIELD_PREP(LTC4282_CLKOUT_MASK, val));
}
/*
* Note the 15HZ conversion rate assumes 12bit ADC which is what we are
* supporting for now.
*/
static const unsigned int ltc4282_out_rates[] = {
LTC4282_CLKOUT_CNV, LTC4282_CLKOUT_SYSTEM
};
static int ltc4282_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
int idx = find_closest(req->rate, ltc4282_out_rates,
ARRAY_SIZE(ltc4282_out_rates));
req->rate = ltc4282_out_rates[idx];
return 0;
}
static unsigned long ltc4282_recalc_rate(struct clk_hw *hw,
unsigned long parent)
{
struct ltc4282_state *st = container_of(hw, struct ltc4282_state,
clk_hw);
u32 clkdiv;
int ret;
ret = regmap_read(st->map, LTC4282_CLK_DIV, &clkdiv);
if (ret)
return 0;
clkdiv = FIELD_GET(LTC4282_CLKOUT_MASK, clkdiv);
if (!clkdiv)
return 0;
if (clkdiv == LTC4282_CLKOUT_INT)
return LTC4282_CLKOUT_SYSTEM;
return LTC4282_CLKOUT_CNV;
}
static void ltc4282_disable(struct clk_hw *clk_hw)
{
struct ltc4282_state *st = container_of(clk_hw, struct ltc4282_state,
clk_hw);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/debugfs.h`, `linux/delay.h`, `linux/device.h`, `linux/hwmon.h`.
- Detected declarations: `struct ltc4282_cache`, `struct ltc4282_state`, `function ltc4282_set_rate`, `function ltc4282_determine_rate`, `function ltc4282_recalc_rate`, `function ltc4282_disable`, `function ltc4282_read_voltage_word`, `function ltc4282_read_voltage_byte_cached`, `function ltc4282_read_voltage_byte`, `function __ltc4282_read_alarm`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: source 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.