drivers/hwmon/pmbus/mp29502.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/mp29502.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/mp29502.c- Extension
.c- Size
- 16613 bytes
- Lines
- 671
- 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/i2c.hlinux/module.hlinux/of_device.hpmbus.h
Detected Declarations
struct mp29502_datafunction mp29502_reg2data_linear11function mp29502_identify_vout_scalefunction mp29502_identify_vout_dividerfunction mp29502_identify_ovp_dividerfunction mp29502_identify_iout_scalefunction mp29502_read_vout_ov_limitfunction mp29502_write_vout_ov_limitfunction mp29502_read_byte_datafunction mp29502_read_word_datafunction mp29502_write_word_datafunction mp29502_identifyfunction mp29502_probe
Annotated Snippet
struct mp29502_data {
struct pmbus_driver_info info;
int vout_scale;
int vout_bottom_div;
int vout_top_div;
int ovp_div;
int iout_scale;
};
#define to_mp29502_data(x) container_of(x, struct mp29502_data, info)
static u16 mp29502_reg2data_linear11(u16 word)
{
s16 exponent;
s32 mantissa;
s64 val;
exponent = ((s16)word) >> 11;
mantissa = ((s16)((word & 0x7ff) << 5)) >> 5;
val = mantissa;
if (exponent >= 0)
val <<= exponent;
else
val >>= -exponent;
return val;
}
static int
mp29502_identify_vout_scale(struct i2c_client *client, struct pmbus_driver_info *info,
int page)
{
struct mp29502_data *data = to_mp29502_data(info);
int ret;
ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
if (ret < 0)
return ret;
ret = i2c_smbus_read_word_data(client, MFR_VOUT_SCALE_LOOP);
if (ret < 0)
return ret;
switch (FIELD_GET(GENMASK(12, 10), ret)) {
case 0:
data->vout_scale = 6400;
break;
case 1:
data->vout_scale = 5120;
break;
case 2:
data->vout_scale = 2560;
break;
case 3:
data->vout_scale = 2048;
break;
case 4:
data->vout_scale = 1024;
break;
case 5:
data->vout_scale = 4;
break;
case 6:
data->vout_scale = 2;
break;
case 7:
data->vout_scale = 1;
break;
default:
data->vout_scale = 1;
break;
}
return 0;
}
static int
mp29502_identify_vout_divider(struct i2c_client *client, struct pmbus_driver_info *info,
int page)
{
struct mp29502_data *data = to_mp29502_data(info);
int ret;
ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
if (ret < 0)
return ret;
ret = i2c_smbus_read_word_data(client, MFR_VOUT_PROT1);
if (ret < 0)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/i2c.h`, `linux/module.h`, `linux/of_device.h`, `pmbus.h`.
- Detected declarations: `struct mp29502_data`, `function mp29502_reg2data_linear11`, `function mp29502_identify_vout_scale`, `function mp29502_identify_vout_divider`, `function mp29502_identify_ovp_divider`, `function mp29502_identify_iout_scale`, `function mp29502_read_vout_ov_limit`, `function mp29502_write_vout_ov_limit`, `function mp29502_read_byte_data`, `function mp29502_read_word_data`.
- 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.