drivers/hwmon/pmbus/ltc2978.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/ltc2978.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/ltc2978.c- Extension
.c- Size
- 29209 bytes
- Lines
- 1015
- 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/delay.hlinux/jiffies.hlinux/kernel.hlinux/module.hlinux/init.hlinux/err.hlinux/slab.hlinux/i2c.hlinux/regulator/driver.hpmbus.h
Detected Declarations
struct ltc2978_dataenum chipsfunction ltc_wait_readyfunction ltc_read_word_datafunction ltc_read_byte_datafunction ltc_write_byte_datafunction ltc_write_bytefunction lin11_to_valfunction ltc_get_maxfunction ltc_get_minfunction ltc2978_read_word_data_commonfunction ltc2978_read_word_datafunction ltc2974_read_word_datafunction ltc2975_read_word_datafunction ltc3880_read_word_datafunction ltc3883_read_word_datafunction ltc2978_clear_peaksfunction ltc2978_write_word_datafunction ltc2978_get_idfunction ltc2978_probe
Annotated Snippet
struct ltc2978_data {
enum chips id;
u16 vin_min, vin_max;
u16 temp_min[LTC2974_NUM_PAGES], temp_max[LTC2974_NUM_PAGES];
u16 vout_min[LTC2978_NUM_PAGES], vout_max[LTC2978_NUM_PAGES];
u16 iout_min[LTC2974_NUM_PAGES], iout_max[LTC2974_NUM_PAGES];
u16 iin_min, iin_max;
u16 pin_min, pin_max;
u16 temp2_max;
struct pmbus_driver_info info;
u32 features;
};
#define to_ltc2978_data(x) container_of(x, struct ltc2978_data, info)
#define FEAT_CLEAR_PEAKS BIT(0)
#define FEAT_NEEDS_POLLING BIT(1)
#define has_clear_peaks(d) ((d)->features & FEAT_CLEAR_PEAKS)
#define needs_polling(d) ((d)->features & FEAT_NEEDS_POLLING)
static int ltc_wait_ready(struct i2c_client *client)
{
unsigned long timeout = jiffies + msecs_to_jiffies(LTC_POLL_TIMEOUT);
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct ltc2978_data *data = to_ltc2978_data(info);
int status;
u8 mask;
if (!needs_polling(data))
return 0;
/*
* LTC3883 does not support LTC_NOT_PENDING, even though
* the datasheet claims that it does.
*/
mask = LTC_NOT_BUSY;
if (data->id != ltc3883)
mask |= LTC_NOT_PENDING;
do {
status = pmbus_read_byte_data(client, 0, LTC2978_MFR_COMMON);
if (status == -EBADMSG || status == -ENXIO) {
/* PEC error or NACK: chip may be busy, try again */
usleep_range(50, 100);
continue;
}
if (status < 0)
return status;
if ((status & mask) == mask)
return 0;
usleep_range(50, 100);
} while (time_before(jiffies, timeout));
return -ETIMEDOUT;
}
static int ltc_read_word_data(struct i2c_client *client, int page, int phase,
int reg)
{
int ret;
ret = ltc_wait_ready(client);
if (ret < 0)
return ret;
return pmbus_read_word_data(client, page, 0xff, reg);
}
static int ltc_read_byte_data(struct i2c_client *client, int page, int reg)
{
int ret;
ret = ltc_wait_ready(client);
if (ret < 0)
return ret;
return pmbus_read_byte_data(client, page, reg);
}
static int ltc_write_byte_data(struct i2c_client *client, int page, int reg, u8 value)
{
int ret;
ret = ltc_wait_ready(client);
if (ret < 0)
return ret;
return pmbus_write_byte_data(client, page, reg, value);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/jiffies.h`, `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/err.h`, `linux/slab.h`, `linux/i2c.h`.
- Detected declarations: `struct ltc2978_data`, `enum chips`, `function ltc_wait_ready`, `function ltc_read_word_data`, `function ltc_read_byte_data`, `function ltc_write_byte_data`, `function ltc_write_byte`, `function lin11_to_val`, `function ltc_get_max`, `function ltc_get_min`.
- 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.