drivers/hwmon/pmbus/aps-379.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/aps-379.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/aps-379.c- Extension
.c- Size
- 3995 bytes
- Lines
- 156
- 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/i2c.hlinux/init.hlinux/kernel.hlinux/module.hlinux/pmbus.hpmbus.h
Detected Declarations
function aps_379_read_byte_datafunction aps_379_read_voutfunction aps_379_read_word_datafunction aps_379_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Hardware monitoring driver for Sony APS-379 Power Supplies
*
* Copyright 2026 Allied Telesis Labs
*/
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pmbus.h>
#include "pmbus.h"
/*
* The VOUT format used by the chip is linear11, not linear16. Provide a hard
* coded VOUT_MODE that says VOUT is in linear mode with a fixed exponent of
* 2^-4.
*/
#define APS_379_VOUT_MODE ((u8)(-4 & 0x1f))
static int aps_379_read_byte_data(struct i2c_client *client, int page, int reg)
{
switch (reg) {
case PMBUS_VOUT_MODE:
return APS_379_VOUT_MODE;
default:
return -ENODATA;
}
}
/*
* The APS-379 uses linear11 format instead of linear16. We've reported the exponent
* via the PMBUS_VOUT_MODE so we just return the mantissa here.
*/
static int aps_379_read_vout(struct i2c_client *client)
{
int ret;
ret = pmbus_read_word_data(client, 0, 0xff, PMBUS_READ_VOUT);
if (ret < 0)
return ret;
return clamp_val(sign_extend32(ret & 0x7ff, 10), 0, 0x3ff);
}
static int aps_379_read_word_data(struct i2c_client *client, int page, int phase, int reg)
{
switch (reg) {
case PMBUS_VOUT_UV_WARN_LIMIT:
case PMBUS_VOUT_OV_WARN_LIMIT:
case PMBUS_VOUT_UV_FAULT_LIMIT:
case PMBUS_VOUT_OV_FAULT_LIMIT:
case PMBUS_IOUT_OC_WARN_LIMIT:
case PMBUS_IOUT_UC_FAULT_LIMIT:
case PMBUS_UT_WARN_LIMIT:
case PMBUS_UT_FAULT_LIMIT:
case PMBUS_OT_WARN_LIMIT:
case PMBUS_OT_FAULT_LIMIT:
case PMBUS_PIN_OP_WARN_LIMIT:
case PMBUS_POUT_OP_WARN_LIMIT:
case PMBUS_MFR_IIN_MAX:
case PMBUS_MFR_PIN_MAX:
case PMBUS_MFR_VOUT_MIN:
case PMBUS_MFR_VOUT_MAX:
case PMBUS_MFR_IOUT_MAX:
case PMBUS_MFR_POUT_MAX:
case PMBUS_MFR_MAX_TEMP_1:
/* These commands return data but it is invalid/un-documented */
return -ENXIO;
case PMBUS_IOUT_OC_FAULT_LIMIT:
/*
* The standard requires this to be a value in Amps but it's
* actually a percentage of the rated output (123A for
* 110-240Vac, 110A for 90-100Vac) which we don't know. Ignore
* it rather than guessing.
*/
return -ENXIO;
case PMBUS_READ_VOUT:
return aps_379_read_vout(client);
default:
return -ENODATA;
}
}
static struct pmbus_driver_info aps_379_info = {
.pages = 1,
.format[PSC_VOLTAGE_OUT] = linear,
.format[PSC_CURRENT_OUT] = linear,
.format[PSC_POWER] = linear,
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/pmbus.h`, `pmbus.h`.
- Detected declarations: `function aps_379_read_byte_data`, `function aps_379_read_vout`, `function aps_379_read_word_data`, `function aps_379_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.