drivers/hwmon/pmbus/mpq7932.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/mpq7932.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/mpq7932.c- Extension
.c- Size
- 4638 bytes
- Lines
- 168
- 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/bits.hlinux/err.hlinux/i2c.hlinux/init.hlinux/kernel.hlinux/module.hlinux/of.hlinux/pmbus.hpmbus.h
Detected Declarations
struct mpq7932_datafunction mpq7932_write_word_datafunction mpq7932_read_word_datafunction mpq7932_probe
Annotated Snippet
struct mpq7932_data {
struct pmbus_driver_info info;
struct pmbus_platform_data pdata;
};
#if IS_ENABLED(CONFIG_SENSORS_MPQ7932_REGULATOR)
static const struct regulator_desc mpq7932_regulators_desc[] = {
PMBUS_REGULATOR_STEP("buck", 0, MPQ7932_N_VOLTAGES,
MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
PMBUS_REGULATOR_STEP("buck", 1, MPQ7932_N_VOLTAGES,
MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
PMBUS_REGULATOR_STEP("buck", 2, MPQ7932_N_VOLTAGES,
MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
PMBUS_REGULATOR_STEP("buck", 3, MPQ7932_N_VOLTAGES,
MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
PMBUS_REGULATOR_STEP("buck", 4, MPQ7932_N_VOLTAGES,
MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
PMBUS_REGULATOR_STEP("buck", 5, MPQ7932_N_VOLTAGES,
MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
};
static const struct regulator_desc mpq7932_regulators_desc_one[] = {
PMBUS_REGULATOR_STEP_ONE_NODE("buck", MPQ7932_N_VOLTAGES,
MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN),
};
#endif
static int mpq7932_write_word_data(struct i2c_client *client, int page, int reg,
u16 word)
{
switch (reg) {
/*
* chip supports only byte access for VOUT_COMMAND otherwise
* access results -EREMOTEIO
*/
case PMBUS_VOUT_COMMAND:
return pmbus_write_byte_data(client, page, reg, word & 0xFF);
default:
return -ENODATA;
}
}
static int mpq7932_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{
switch (reg) {
/*
* chip supports neither (PMBUS_VOUT_MARGIN_HIGH, PMBUS_VOUT_MARGIN_LOW)
* nor (PMBUS_MFR_VOUT_MIN, PMBUS_MFR_VOUT_MAX). As a result set voltage
* fails due to error in pmbus_regulator_get_low_margin, so faked.
*/
case PMBUS_MFR_VOUT_MIN:
return 0;
case PMBUS_MFR_VOUT_MAX:
return MPQ7932_VOUT_MAX;
/*
* chip supports only byte access for VOUT_COMMAND otherwise
* access results in -EREMOTEIO
*/
case PMBUS_READ_VOUT:
return pmbus_read_byte_data(client, page, PMBUS_VOUT_COMMAND);
default:
return -ENODATA;
}
}
static int mpq7932_probe(struct i2c_client *client)
{
struct mpq7932_data *data;
struct pmbus_driver_info *info;
struct device *dev = &client->dev;
int i;
data = devm_kzalloc(dev, sizeof(struct mpq7932_data), GFP_KERNEL);
if (!data)
return -ENOMEM;
info = &data->info;
info->pages = (int)(unsigned long)device_get_match_data(&client->dev);
info->format[PSC_VOLTAGE_OUT] = direct;
info->m[PSC_VOLTAGE_OUT] = 160;
info->b[PSC_VOLTAGE_OUT] = -33;
for (i = 0; i < info->pages; i++) {
info->func[i] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_STATUS_TEMP;
}
Annotation
- Immediate include surface: `linux/bits.h`, `linux/err.h`, `linux/i2c.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/pmbus.h`.
- Detected declarations: `struct mpq7932_data`, `function mpq7932_write_word_data`, `function mpq7932_read_word_data`, `function mpq7932_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.