drivers/hwmon/pmbus/delta-ahe50dc-fan.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/delta-ahe50dc-fan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/delta-ahe50dc-fan.c- Extension
.c- Size
- 3897 bytes
- Lines
- 131
- 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/kernel.hlinux/module.hlinux/pmbus.hpmbus.h
Detected Declarations
function ahe50dc_fan_write_bytefunction ahe50dc_fan_read_word_datafunction ahe50dc_fan_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Delta AHE-50DC power shelf fan control module driver
*
* Copyright 2021 Zev Weiss <zev@bewilderbeest.net>
*/
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pmbus.h>
#include "pmbus.h"
#define AHE50DC_PMBUS_READ_TEMP4 0xd0
static int ahe50dc_fan_write_byte(struct i2c_client *client, int page, u8 value)
{
/*
* The CLEAR_FAULTS operation seems to sometimes (unpredictably, perhaps
* 5% of the time or so) trigger a problematic phenomenon in which the
* fan speeds surge momentarily and at least some (perhaps all?) of the
* system's power outputs experience a glitch.
*
* However, according to Delta it should be OK to simply not send any
* CLEAR_FAULTS commands (the device doesn't seem to be capable of
* reporting any faults anyway), so just blackhole them unconditionally.
*/
return value == PMBUS_CLEAR_FAULTS ? -EOPNOTSUPP : -ENODATA;
}
static int ahe50dc_fan_read_word_data(struct i2c_client *client, int page, int phase, int reg)
{
/* temp1 in (virtual) page 1 is remapped to mfr-specific temp4 */
if (page == 1) {
if (reg == PMBUS_READ_TEMPERATURE_1)
return i2c_smbus_read_word_data(client, AHE50DC_PMBUS_READ_TEMP4);
return -EOPNOTSUPP;
}
/*
* There's a fairly limited set of commands this device actually
* supports, so here we block attempts to read anything else (which
* return 0xffff and would cause confusion elsewhere).
*/
switch (reg) {
case PMBUS_STATUS_WORD:
case PMBUS_FAN_COMMAND_1:
case PMBUS_FAN_COMMAND_2:
case PMBUS_FAN_COMMAND_3:
case PMBUS_FAN_COMMAND_4:
case PMBUS_STATUS_FAN_12:
case PMBUS_STATUS_FAN_34:
case PMBUS_READ_VIN:
case PMBUS_READ_TEMPERATURE_1:
case PMBUS_READ_TEMPERATURE_2:
case PMBUS_READ_TEMPERATURE_3:
case PMBUS_READ_FAN_SPEED_1:
case PMBUS_READ_FAN_SPEED_2:
case PMBUS_READ_FAN_SPEED_3:
case PMBUS_READ_FAN_SPEED_4:
return -ENODATA;
default:
return -EOPNOTSUPP;
}
}
static struct pmbus_driver_info ahe50dc_fan_info = {
.pages = 2,
.format[PSC_FAN] = direct,
.format[PSC_TEMPERATURE] = direct,
.format[PSC_VOLTAGE_IN] = direct,
.m[PSC_FAN] = 1,
.b[PSC_FAN] = 0,
.R[PSC_FAN] = 0,
.m[PSC_TEMPERATURE] = 1,
.b[PSC_TEMPERATURE] = 0,
.R[PSC_TEMPERATURE] = 1,
.m[PSC_VOLTAGE_IN] = 1,
.b[PSC_VOLTAGE_IN] = 0,
.R[PSC_VOLTAGE_IN] = 3,
.func[0] = PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
PMBUS_HAVE_VIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_FAN34 |
PMBUS_HAVE_STATUS_FAN12 | PMBUS_HAVE_STATUS_FAN34 | PMBUS_PAGE_VIRTUAL,
.func[1] = PMBUS_HAVE_TEMP | PMBUS_PAGE_VIRTUAL,
.write_byte = ahe50dc_fan_write_byte,
.read_word_data = ahe50dc_fan_read_word_data,
};
/*
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/kernel.h`, `linux/module.h`, `linux/pmbus.h`, `pmbus.h`.
- Detected declarations: `function ahe50dc_fan_write_byte`, `function ahe50dc_fan_read_word_data`, `function ahe50dc_fan_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.