drivers/hwmon/pmbus/lt7182s.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/lt7182s.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/lt7182s.c- Extension
.c- Size
- 5119 bytes
- Lines
- 196
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bits.hlinux/err.hlinux/i2c.hlinux/init.hlinux/kernel.hlinux/module.hlinux/of.hpmbus.h
Detected Declarations
function Copyrightfunction lt7182s_write_word_datafunction lt7182s_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Hardware monitoring driver for Analog Devices LT7182S
*
* Copyright (c) 2022 Guenter Roeck
*
*/
#include <linux/bits.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include "pmbus.h"
#define LT7182S_NUM_PAGES 2
#define MFR_READ_EXTVCC 0xcd
#define MFR_READ_ITH 0xce
#define MFR_CONFIG_ALL_LT7182S 0xd1
#define MFR_IOUT_PEAK 0xd7
#define MFR_ADC_CONTROL_LT7182S 0xd8
#define MFR_DEBUG_TELEMETRY BIT(0)
#define MFR_VOUT_PEAK 0xdd
#define MFR_VIN_PEAK 0xde
#define MFR_TEMPERATURE_1_PEAK 0xdf
#define MFR_CLEAR_PEAKS 0xe3
#define MFR_CONFIG_IEEE BIT(8)
static int lt7182s_read_word_data(struct i2c_client *client, int page, int phase, int reg)
{
int ret;
switch (reg) {
case PMBUS_VIRT_READ_VMON:
if (page == 0 || page == 1)
ret = pmbus_read_word_data(client, page, phase, MFR_READ_ITH);
else
ret = pmbus_read_word_data(client, 0, phase, MFR_READ_EXTVCC);
break;
case PMBUS_VIRT_READ_IOUT_MAX:
ret = pmbus_read_word_data(client, page, phase, MFR_IOUT_PEAK);
break;
case PMBUS_VIRT_READ_VOUT_MAX:
ret = pmbus_read_word_data(client, page, phase, MFR_VOUT_PEAK);
break;
case PMBUS_VIRT_READ_VIN_MAX:
ret = pmbus_read_word_data(client, page, phase, MFR_VIN_PEAK);
break;
case PMBUS_VIRT_READ_TEMP_MAX:
ret = pmbus_read_word_data(client, page, phase, MFR_TEMPERATURE_1_PEAK);
break;
case PMBUS_VIRT_RESET_VIN_HISTORY:
ret = (page == 0) ? 0 : -ENODATA;
break;
default:
ret = -ENODATA;
break;
}
return ret;
}
static int lt7182s_write_word_data(struct i2c_client *client, int page, int reg, u16 word)
{
int ret;
switch (reg) {
case PMBUS_VIRT_RESET_VIN_HISTORY:
ret = pmbus_write_byte(client, 0, MFR_CLEAR_PEAKS);
break;
default:
ret = -ENODATA;
break;
}
return ret;
}
static struct pmbus_driver_info lt7182s_info = {
.pages = LT7182S_NUM_PAGES,
.format[PSC_VOLTAGE_IN] = linear,
.format[PSC_VOLTAGE_OUT] = linear,
.format[PSC_CURRENT_IN] = linear,
.format[PSC_CURRENT_OUT] = linear,
.format[PSC_TEMPERATURE] = linear,
.format[PSC_POWER] = linear,
Annotation
- Immediate include surface: `linux/bits.h`, `linux/err.h`, `linux/i2c.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `pmbus.h`.
- Detected declarations: `function Copyright`, `function lt7182s_write_word_data`, `function lt7182s_probe`.
- 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.