drivers/hwmon/pmbus/mp9941.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/mp9941.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/mp9941.c- Extension
.c- Size
- 7735 bytes
- Lines
- 320
- 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/bitfield.hlinux/bits.hlinux/i2c.hlinux/module.hlinux/of_device.hpmbus.h
Detected Declarations
struct mp9941_datafunction mp9941_set_vout_formatfunction mp9941_identify_vid_resolutionfunction mp9941_identify_iin_scalefunction mp9941_identifyfunction mp9941_read_word_datafunction mp9941_write_word_datafunction mp9941_probe
Annotated Snippet
struct mp9941_data {
struct pmbus_driver_info info;
int vid_resolution;
};
#define to_mp9941_data(x) container_of(x, struct mp9941_data, info)
static int mp9941_set_vout_format(struct i2c_client *client)
{
int ret;
ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
if (ret < 0)
return ret;
ret = i2c_smbus_read_word_data(client, MFR_RESO_SET);
if (ret < 0)
return ret;
/*
* page = 0, MFR_RESO_SET[7:6] defines the vout format
* 2'b11 set the vout format as direct
*/
ret = (ret & ~GENMASK(7, 6)) | FIELD_PREP(GENMASK(7, 6), 3);
return i2c_smbus_write_word_data(client, MFR_RESO_SET, ret);
}
static int
mp9941_identify_vid_resolution(struct i2c_client *client, struct pmbus_driver_info *info)
{
struct mp9941_data *data = to_mp9941_data(info);
int ret;
/*
* page = 2, MFR_VR_MULTI_CONFIG_R1[4:4] defines rail1 vid step value
* 1'b0 represents the vid step value is 10mV
* 1'b1 represents the vid step value is 5mV
*/
ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 2);
if (ret < 0)
return ret;
ret = i2c_smbus_read_word_data(client, MFR_VR_MULTI_CONFIG_R1);
if (ret < 0)
return ret;
if (FIELD_GET(GENMASK(4, 4), ret))
data->vid_resolution = 5;
else
data->vid_resolution = 10;
return 0;
}
static int mp9941_identify_iin_scale(struct i2c_client *client)
{
int ret;
ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
if (ret < 0)
return ret;
ret = i2c_smbus_read_word_data(client, MFR_RESO_SET);
if (ret < 0)
return ret;
ret = (ret & ~GENMASK(3, 2)) | FIELD_PREP(GENMASK(3, 2), 0);
ret = i2c_smbus_write_word_data(client, MFR_RESO_SET, ret);
if (ret < 0)
return ret;
/*
* page = 2, MFR_ICC_MAX[15:13] defines the iin scale
* 3'b000 set the iout scale as 0.5A/Lsb
*/
ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 2);
if (ret < 0)
return ret;
ret = i2c_smbus_read_word_data(client, MFR_ICC_MAX);
if (ret < 0)
return ret;
ret = (ret & ~GENMASK(15, 13)) | FIELD_PREP(GENMASK(15, 13), 0);
return i2c_smbus_write_word_data(client, MFR_ICC_MAX, ret);
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/i2c.h`, `linux/module.h`, `linux/of_device.h`, `pmbus.h`.
- Detected declarations: `struct mp9941_data`, `function mp9941_set_vout_format`, `function mp9941_identify_vid_resolution`, `function mp9941_identify_iin_scale`, `function mp9941_identify`, `function mp9941_read_word_data`, `function mp9941_write_word_data`, `function mp9941_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.