drivers/hwmon/pmbus/mpq8785.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/mpq8785.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/mpq8785.c- Extension
.c- Size
- 4877 bytes
- Lines
- 194
- 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/bitops.hlinux/module.hlinux/property.hlinux/of_device.hpmbus.h
Detected Declarations
enum chipsfunction mpq8785_identifyfunction mpq8785_read_byte_datafunction mpm82504_read_word_datafunction mpq8785_probe
Annotated Snippet
if ((ret >> 5) == 1) {
/*
* The MPQ8785 chip reports VOUT_MODE as VID mode, but the driver
* treats VID as direct mode. Without this, identification would fail
* due to mode mismatch.
* This override ensures the reported mode matches the driver
* configuration, allowing successful initialization.
*/
return PB_VOUT_MODE_DIRECT;
}
return ret;
default:
return -ENODATA;
}
}
static int mpm82504_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{
int ret;
ret = pmbus_read_word_data(client, page, phase, reg);
if (ret < 0 || reg != PMBUS_READ_TEMPERATURE_1)
return ret;
/* Fix PMBUS_READ_TEMPERATURE_1 signedness */
return sign_extend32(ret, MPM82504_READ_TEMPERATURE_1_SIGN_POS) & 0xffff;
}
static struct pmbus_driver_info mpq8785_info = {
.pages = 1,
.format[PSC_VOLTAGE_IN] = direct,
.format[PSC_CURRENT_OUT] = direct,
.format[PSC_TEMPERATURE] = direct,
.m[PSC_VOLTAGE_IN] = 4,
.b[PSC_VOLTAGE_IN] = 0,
.R[PSC_VOLTAGE_IN] = 1,
.m[PSC_CURRENT_OUT] = 16,
.b[PSC_CURRENT_OUT] = 0,
.R[PSC_CURRENT_OUT] = 0,
.m[PSC_TEMPERATURE] = 1,
.b[PSC_TEMPERATURE] = 0,
.R[PSC_TEMPERATURE] = 0,
.func[0] =
PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT |
PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
};
static const struct i2c_device_id mpq8785_id[] = {
{ .name = "mpm3695", .driver_data = mpm3695 },
{ .name = "mpm3695-25", .driver_data = mpm3695_25 },
{ .name = "mpm82504", .driver_data = mpm82504 },
{ .name = "mpq8785", .driver_data = mpq8785 },
{ }
};
MODULE_DEVICE_TABLE(i2c, mpq8785_id);
static const struct of_device_id __maybe_unused mpq8785_of_match[] = {
{ .compatible = "mps,mpm3695", .data = (void *)mpm3695 },
{ .compatible = "mps,mpm3695-25", .data = (void *)mpm3695_25 },
{ .compatible = "mps,mpm82504", .data = (void *)mpm82504 },
{ .compatible = "mps,mpq8785", .data = (void *)mpq8785 },
{}
};
MODULE_DEVICE_TABLE(of, mpq8785_of_match);
static int mpq8785_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct pmbus_driver_info *info;
enum chips chip_id;
u32 voltage_scale;
int ret;
info = devm_kmemdup(dev, &mpq8785_info, sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;
if (dev->of_node)
chip_id = (kernel_ulong_t)of_device_get_match_data(dev);
else
chip_id = (kernel_ulong_t)i2c_get_match_data(client);
switch (chip_id) {
case mpm3695:
case mpm3695_25:
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/bitops.h`, `linux/module.h`, `linux/property.h`, `linux/of_device.h`, `pmbus.h`.
- Detected declarations: `enum chips`, `function mpq8785_identify`, `function mpq8785_read_byte_data`, `function mpm82504_read_word_data`, `function mpq8785_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.