drivers/hwmon/pmbus/ltc4286.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/ltc4286.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/ltc4286.c- Extension
.c- Size
- 4918 bytes
- Lines
- 177
- 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/err.hlinux/i2c.hlinux/init.hlinux/kernel.hlinux/module.hlinux/pmbus.hpmbus.h
Detected Declarations
function ltc4286_probefunction strncmp
Annotated Snippet
strncmp(block_buffer, "LTC", LTC4286_MFR_ID_SIZE)) {
return dev_err_probe(&client->dev, -ENODEV,
"Manufacturer id mismatch\n");
}
ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, block_buffer);
if (ret < 0) {
return dev_err_probe(&client->dev, ret,
"Failed to read manufacturer model\n");
}
for (mid = ltc4286_id; mid->name[0]; mid++) {
if (!strncasecmp(mid->name, block_buffer, strlen(mid->name)))
break;
}
if (!mid->name[0])
return dev_err_probe(&client->dev, -ENODEV,
"Unsupported device\n");
if (of_property_read_u32(client->dev.of_node,
"shunt-resistor-micro-ohms", &rsense))
rsense = 300; /* 0.3 mOhm if not set via DT */
if (rsense == 0)
return -EINVAL;
/* Check for the latter MBR value won't overflow */
if (rsense > (INT_MAX / 1024))
return -EINVAL;
info = devm_kmemdup(&client->dev, <c4286_info, sizeof(*info),
GFP_KERNEL);
if (!info)
return -ENOMEM;
/* Check MFR1 CONFIG register bit 1 VRANGE_SELECT before driver loading */
vrange_oval = i2c_smbus_read_word_data(client, LTC4286_MFR_CONFIG1);
if (vrange_oval < 0)
return dev_err_probe(&client->dev, vrange_oval,
"Failed to read manufacturer configuration one\n");
vrange_nval = vrange_oval;
if (device_property_read_bool(&client->dev, "adi,vrange-low-enable")) {
vrange_nval &=
~VRANGE_SELECT_BIT; /* VRANGE_SELECT = 0, 25.6 volts */
info->m[PSC_VOLTAGE_IN] = 128;
info->m[PSC_VOLTAGE_OUT] = 128;
info->m[PSC_POWER] = 4 * rsense;
} else {
vrange_nval |=
VRANGE_SELECT_BIT; /* VRANGE_SELECT = 1, 102.4 volts */
info->m[PSC_POWER] = rsense;
}
if (vrange_nval != vrange_oval) {
/* Set MFR1 CONFIG register bit 1 VRANGE_SELECT */
ret = i2c_smbus_write_word_data(client, LTC4286_MFR_CONFIG1,
vrange_nval);
if (ret < 0)
return dev_err_probe(&client->dev, ret,
"Failed to set vrange\n");
}
info->m[PSC_CURRENT_OUT] = 1024 * rsense;
return pmbus_do_probe(client, info);
}
static const struct of_device_id ltc4286_of_match[] = {
{ .compatible = "lltc,ltc4286" },
{ .compatible = "lltc,ltc4287" },
{}
};
static struct i2c_driver ltc4286_driver = {
.driver = {
.name = "ltc4286",
.of_match_table = ltc4286_of_match,
},
.probe = ltc4286_probe,
.id_table = ltc4286_id,
};
module_i2c_driver(ltc4286_driver);
MODULE_AUTHOR("Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>");
MODULE_DESCRIPTION("PMBUS driver for LTC4286 and compatibles");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS("PMBUS");
Annotation
- Immediate include surface: `linux/err.h`, `linux/i2c.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/pmbus.h`, `pmbus.h`.
- Detected declarations: `function ltc4286_probe`, `function strncmp`.
- 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.